We can substract two Numbers using PHP Program. We need html elements like form tag, input tag.
$_POST variable is used to retrive 2 numbers.
We can substract two Numbers using PHP Program. We need html elements like form tag, input tag.
$_POST variable is used to retrive 2 numbers.
Example :
<?php
if(isset($_POST['submit']))
{
$num1=$_POST['num1'];
$num2=$_POST['num2'];
$result=$num1-$num2;
$result="Subtraction of " .$num1. " and ".$num2. " : " .$result;
}else
{
$result="";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>PHP Maths Program - Subtraction two number by aryatechno</title>
</head>
<body>
<table>
<form name="sub" method="post">
<tr>
<td colspan="2"><strong>Maths Subtraction </strong></td>
</tr>
<tr>
<td>Number 1 :</td>
<td><input type="text" name="num1" value="<?=$_POST['num1'] ?>" required></td>
</tr>
<tr>
<td>Number 2 :</td>
<td><input type="text" name="num2" value="<?=$_POST['num2'] ?>" required></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Subtraction " name="submit" /></td>
</tr>
<tr>
<td colspan="2"><strong><?=$result ?></strong></td>
</tr>
</form>
</table>
</body>
</html>
Output :
Comments