html - Unable to display sum of data in PHP -
i using following environment:
php version 5.6 apache 2.4 o.s windows 10.
following code form , php script handles form submission. when submit form blank page. doesn't print "total:". also, if remove isset condition, 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 2 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; } ?>
i found reason issue. seems issue in php storm version 10.
i have uninstalled ver 10 , installed ver 9. works ok. here's link
hope helps..
Comments
Post a Comment