CherryLips Posted February 16, 2014 Share Posted February 16, 2014 Hello, I am completely new to PHP and taking at the community college. My first assignment was to create a form and so I decided to create a calculation form. My problem is that it isnt returning any output and I think there may be an issue with the submit button. I am using xampp and I also have dreamweaver connected to my server. I haven't quite fifured out the error reporting for apache, but dreamweaver is giving no syntax errors. The link to my form is http://www.cherrycreatives.com/php/calculate_form.html and http://www.cherrycreatives.com/php/calculate.php Here is the code for each file(they are also attached): <!doctype html><html><head><meta charset="UTF-8"><title>PHP Form by Carrie Carrigan</title></head><body><form method="post" action="calculate.php"><p>Value: 1 <input type="text" name="val1" size=10></p><p>Value: 2 <input type="text" name="val2" size=10></p><p>Calculation:</p><input type="radio" name="calc" value="add"> add <br><input type="radio" name="calc" value="subtract"> subtract <br><input type="radio" name="calc" value="multiply"> multiply <br><input type="radio" name="calc" value="divide"> divide <br></p><p><input type="button" name="submit" value="calculate"></p></form></body></html> ------------------------------------------------------------------------------- <!doctype html><html><head><meta charset="UTF-8"><title>Calculation Result</title></head><?phpif (($_POST[val1] == "") || ($_POST[val2] == "") || ($_POST[calc] == '')) { header("Location: calculate_form.html"); exit;}if ($_POST[calc] == "add") { $result = $_POST[val1] + $_POST[val2];}else if ($_POST[calc] == "subtract") { $result = $_POST[val1] - $_POST[val2];}else if ($_POST[calc] == "multiply") { $result = $_POST[val1] * $_POST[val2];}else if ($_POST[calc] == "divide") { $result = $_POST[val1] / $_POST[val2];}?><body><p>The result of the calculation is: <?php echo "$result";?></p></body></html> calculate.php calculate_form.html Link to comment https://forums.phpfreaks.com/topic/286238-my-first-php-script-form-not-returning-output/ Share on other sites More sharing options...
Barand Posted February 16, 2014 Share Posted February 16, 2014 try <input type="submit" name="submit" value="calculate"> Link to comment https://forums.phpfreaks.com/topic/286238-my-first-php-script-form-not-returning-output/#findComment-1469153 Share on other sites More sharing options...
Ch0cu3r Posted February 16, 2014 Share Posted February 16, 2014 I haven't quite fifured out the error reporting for apache, but dreamweaver is giving no syntax errors. Not Apache you want to configure, but PHP. You need to open php.ini and set error_reporting to E_ALL and set display_errors to ON. Make sure you restart apache after any changes to the php.ini Link to comment https://forums.phpfreaks.com/topic/286238-my-first-php-script-form-not-returning-output/#findComment-1469154 Share on other sites More sharing options...
CherryLips Posted February 16, 2014 Author Share Posted February 16, 2014 Thank you! I feel like an idiot because the issue was in my HTML and not PHP. I am beyond thankful Will set error reporting now. Link to comment https://forums.phpfreaks.com/topic/286238-my-first-php-script-form-not-returning-output/#findComment-1469168 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.