₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,197 members, 8,510,620 topics. Date: Friday, 30 October 2026 at 05:38 PM

Toggle theme

Code For PHP Assignment - Programming - Nairaland

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

1 Reply (Go Down)

Code For PHP Assignment by sunpumping(op): 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):
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

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

Benefits Of PYTHON Programming As Career For Everyone Interested In IT Success • Vanhack Talent Accelerator Africa (feb 2018) Apply Now! • Facebook Group For Sale!!!