Bepo Posted May 28, 2013 Share Posted May 28, 2013 Hey, I'm very new to PHP and I'm trying to create a form that posts data to a PHP document. Here's what I have so far: form.html: <form action="phpdoc.php" method="post"> <input type="checkbox" name="fun" value="yes" />Fun <input type="checkbox" name="ent" value="yes" />Entertaining <input type="checkbox" name="inf" value="yes" />Informative <br> <input type="submit" name="formSubmit" value="Submit" /> </form> phpdoc.php: <?php if(isset($_POST['fun']) && $_POST['fun'] == 'yes') { print "Try fdajkfda."; } else { print "You aren't fun."; } ?> The objective is to create a form with checkboxes, and so far, if you select the "fun" checkbox and submit the form, it will send the data to the phpdoc.php and the form will then print something depending on your selection. The problem is, the form isn't printing anything at all. This is a really amateur problem so I thank you for whatever help you can give Quote Link to comment https://forums.phpfreaks.com/topic/278487-beginner-form-problem/ Share on other sites More sharing options...
taquitosensei Posted May 28, 2013 Share Posted May 28, 2013 (edited) Hey, I'm very new to PHP and I'm trying to create a form that posts data to a PHP document. Here's what I have so far: form.html: <form action="phpdoc.php" method="post"> <input type="checkbox" name="fun" value="yes" />Fun <input type="checkbox" name="ent" value="yes" />Entertaining <input type="checkbox" name="inf" value="yes" />Informative <br> <input type="submit" name="formSubmit" value="Submit" /> </form> phpdoc.php: <?php if(isset($_POST['fun']) && $_POST['fun'] == 'yes') { print "Try fdajkfda."; } else { print "You aren't fun."; } ?> The objective is to create a form with checkboxes, and so far, if you select the "fun" checkbox and submit the form, it will send the data to the phpdoc.php and the form will then print something depending on your selection. The problem is, the form isn't printing anything at all. This is a really amateur problem so I thank you for whatever help you can give You can do print_r($_REQUEST); at the top of phpdoc.php to see what kind of values are actually being posted. If you do that you should be able to see right away why this isn't working. Edited May 28, 2013 by taquitosensei Quote Link to comment https://forums.phpfreaks.com/topic/278487-beginner-form-problem/#findComment-1432789 Share on other sites More sharing options...
ginerjm Posted May 29, 2013 Share Posted May 29, 2013 turn on error reporting, set your error level to show all errors. (Yes - I know you''ll have to do some research first!) Also - try adding an exit() to end your script properly. Quote Link to comment https://forums.phpfreaks.com/topic/278487-beginner-form-problem/#findComment-1432973 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.