Php simple calculator
index.html
<html><title>A simple math calculator</title>
<body>
Insert two numbers in the next form and hit submit button <br>
<form action="TextFieldValue.php" method="post">
Firstnumber: <input name="num1" type="text" /><br>
Secondnumber: <input name="num2" type="text" />
<input type="submit" />
</form>
</body>
</html>
TestFieldValue.php
<html>
<head>
<title>Simple Math With User Input</title>
</head>
<body>
<?php
$num1 = $_POST['num1'];
$num2 = $_POST['num2'];
$a = $num1 + $num2;
$b = $num1 - $num2;
echo "The sum of the two numbers is ". $a;
echo "The difference of the two numbers is ". $b;
?>
</body>
</html>
Comments
Post a Comment