PHP Program - Add two Numbers

We have created below PHP Program to add two Numbers. HTML <form> tag with post method is used to submit two numbers.

<input type="submit" value="Add" name="submit" /> html tag is used to submit html form.

<input type="text" name="num1" required> and <input type="text" name="num2" required> are used to enter numbers for getting answer of addition.

$_POST variable is used to retrive 2 numbers for performing addition .

Example :

echo "<b>Addition of " .$num1. " and ".$num2. " :</b> " .$result;
<!DOCTYPE html>
<title>PHP Program - Add two number by aryatechno</title>
<form name="sum" method="post">
<td>Number 1 :</td>
<td><input type="text" name="num1" required></td>
<td>Number 2 :</td>
<td><input type="text" name="num2" required></td>
<td><input type="submit" value="Add" name="submit" /></td>

Output :


Leave a Reply

Your email address will not be published. Required fields are marked *