I am typing a simple codes in PHP and HTML. How can I display the result in same page of browser not in another window tab or page?
Following is the simple HTML formula code:
To add two numbers and display on the same page
<html>
<head>
<title> Sum of two numbers </title>
<body>
<form action="sum.php" method="POST">
First Number: <input type="Text" Name="Num1"><br>
Second Number: <input type="Text" Name="Num2"><p>
<input type="Submit" value="Calculate">
</form>
</body>
</html>
and sum.php file is as follows.
<?php
// add First and Second Numbers
$sum = $_POST["Num1"] + $_POST["Num2"];
// their sum is diplayed as
echo "The sum of First Number (".$_POST["Num1"].") and
Second Number (".$_POST["Num2"].") is $sum";
?>
1 Answer