I am using the following environment:
PHP version 5.6 Apache 2.4 O.S Windows 10.
Following is the code for my form and the PHP script that handles the form submission. When I submit the form I get a blank page. It doesn't print "Total:". Also, if I remove the isset
condition, I get the following error:
"Notice: Undefined index: value1 in F:\small php projects\addnnum.php on line 5"
"Notice: Undefined index: value2 in F:\small php projects\addnnum.php on line 6"
addnum.html
<!DOCTYPE html>
<html>
<title>PHP - Add two numbers</title>
<body>
<form action="addnnum.php" method="post">
<input type="number" name="value1" value="0" />
<input type="number" name="value2" value="0" />
<input type="submit" name="submit" value="Calculate values"/>
</form>
</body>
</html>
addnnum.php
<?php
echo "Test";
if (isset($_POST['submit']))
{
$value1 = $_POST['value1'];
$value2 = $_POST['value2'];
$sum = $value1 + $value2;
echo "Total :" . $sum;
}
?>