Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,849 members, 7,810,274 topics. Date: Saturday, 27 April 2024 at 04:20 AM

Code For PHP Assignment - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Code For PHP Assignment (1021 Views)

A Thread For PHP Code Igniter Framework Tutorial / Looking For Php Freelancers To Work On A Big Project With Me / SMS Gateway For Php (2) (3) (4)

(1) (Reply) (Go Down)

Code For PHP Assignment by sunpumping: 2:51pm On Nov 07, 2017
Pls I need a php code for addition of two numbers together. I am to add input tag to it and place holder. Pls help me. Thanks and God bless.
Re: Code For PHP Assignment by Darey00(m): 5:27pm On Nov 07, 2017
I only know Javascript ,but you can draw inspiration from this



<form>
<input type = "number" placeholder= "first number">


<input type = "number" id='f' placeholder= "second number">


<input type = "number" id='result' placeholder= "second number">


<input type = "button" id='result' type="submit">
</form>



<script>


function add(){


var firstNumber =
document.getElementById('f').value;



var secondNumber =
document.getElementById('s').value;



var add = first + second;



document.getElementById('result').
INNERHTML = "result is "+ add;



}

document.getElementById('result').addEventListener ('click', add, false);
</script>
Re: Code For PHP Assignment by ANTONINEUTRON(m): 5:31pm On Nov 07, 2017
i don't understand your question that much, but try this.


<!DOCTYPE html>
<html lang="en">
<head>
<title>Untitled</title>
</head>
<body>
<form action='' method='post'>
<input name='first_num' type='text' placeholder='First Number here' />
<input name='second_num' type='text' placeholder='Second Number here' />
<input type='submit' value='Add Number' />
</form>
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
$sum = $_POST['first_num'] + $_POST['second_num'];
echo $sum;
}
?>
</body>
</html>
Re: Code For PHP Assignment by francollimasso: 11:41pm On Nov 07, 2017
<!DOCTYPE html> <html lang="en"> <head> <title>Untitled</title> </head> <body> <form action='' method='post'> <input name='first_num' type='number' plac <input name='second_num' type='number' plac <input type='submit' value='Add Number' / </form> <?php if($_SERVER['REQUEST_METHOD']=='POST'){ $sum = $_POST['first_num'] + $_POST['sec echo $sum; } ?> </body> </html>

(1) (Reply)

Which ICT Skill Should He Get? / Apply For Google's $2 Million Grant For Nigerians / New 1 TB External Or Internal Sata Big Harddisk For Just 15k

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.