Create Form containing the menu selections of operations and inputting the numbers.
(menu.html)
<html>
<form method="POST" action="menu.php">
Enter 1st Number:<input type="text" name="n1"><br>
Enter 2nd Number:<input type="text" name="n2"><br>
<h3>Select the operation</h3><br>
Addition<input type="radio" name="n3" value="add"><br>
Subtraction<input type="radio" name="n3" value="sub"><br>
Multiplication<input type="radio" name="n3" value="mul"><br>
Division<input type="radio" name="n3" value="div"><br>
Remainder<input type="radio" name="n3" value="rem"><br>
<input type="submit" value="submit">
</form>
</html>
Embed The Php File
(menu.php)
<?php
$a=$_POST["n1"];
$b=$_POST["n2"];
$r=$_POST["n3"];
if($r=="add") {
$ope=$a+$b;
echo "Addition is $ope";
}
if($r=="sub") {
$ope=$a-$b;
echo "Subtraction is $ope";
}
if($r=="mul") {
$ope=$a*$b;
echo "Multiplication is $ope";
}
if($r=="div") {
$ope=$a/$b;
echo "Division is $ope";
}
if($r=="rem") {
$ope=$a%$b;
echo "Remainder is $ope";
}
?>
Comments
Post a Comment