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 Quote Link to comment https://forums.phpfreaks.com/topic/286238-my-first-php-script-form-not-returning-output/ Share on other sites More sharing options...
Solution Barand Posted February 16, 2014 Solution Share Posted February 16, 2014 try <input type="submit" name="submit" value="calculate"> Quote 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 (edited) 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 Edited February 16, 2014 by Ch0cu3r Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.