By Team Escalera
on 31 Oct 2017 03:03 PM
  • PHP training

A Simple method to take user input and calculate the sum of two numbers in php is given below :

First Create an HTML Form with two text input fields and one submit button

<form method=”post”>
<input type=”text” name=”firstnumber”>

<input type=”text” name=”secondnumber”>

<input type=”submit” name=”Calculate”>

if (isset($_POST[‘Calculate’])){

$firstnumber = $_POST[‘firstnumber’];

$secondnumber = $_POST[‘secondnumber’];

$sum = $firstnumber + $secondnumber;

echo “The Sum is : ” . $sum;
else {
echo “Please insert the numbers to calculate the sum.”; 


Comments (0)

Leave A Comment