We have created below PHP Program to divide two Numbers. HTML <form> tag with post method is used to submit two numbers.
$_POST variable is used to retrive 2 numbers for performing Division.
Here, we have used 2 text field, 1 submit button and 1 form tag.
Example :
<?php
if(isset($_POST['submit']))
{
$num1=$_POST['num1'];
$num2=$_POST['num2'];
$result=$num1*$num2;
$result="Division of " .$num1. " and ".$num2. " : " .$result;
}else
{
$result="";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>PHP Maths Program - Division of two number by aryatechno</title>
</head>
<body>
<table>
<form name="sub" method="post">
<tr>
<td colspan="2"><strong>Maths Division program</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="Division" name="submit" /></td>
</tr>
<tr>
<td colspan="2"><strong><?=$result ?></strong></td>
</tr>
</form>
</table>
</body>
</html>
Output :
Comments