raphael75 Posted February 15, 2013 Share Posted February 15, 2013 We have a Debian Linux server with Apache2. One page, feedback.php has a super-simple form: <form action="feedback.php" method="post"> <div class="type"><input type="radio" name="type" id="compliment" value="compliment" /><label for="compliment">Compliment</label></div> <div class="type"><input type="radio" name="type" id="complaint" value="complaint" /><label for="complaint">Complaint</label></div> <div class="type"><input type="radio" name="type" id="general" value="general" /><label for="general">General</label></div> <br /> <input type="submit" name="submit" class="begin_comments" value="Begin Comments" /> <br /> <br /> <br /> <span class="error"></span> </form> This form posts back to itself, and handles it like this: PHP Code: session_start();if ($_SERVER['REQUEST_METHOD'] == 'POST') {if (isset($_POST['type'])) {$_SESSION['type'] = $_POST['type'];//echo $_SERVER['REQUEST_METHOD'];header('Location: form.php');}else {$error = 'You must select a comment type to begin';}} However, when form.php loads, $_POST, $_GET, or $_REQUEST are all empty arrays. What could cause this? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/274527-form-not-posting/ Share on other sites More sharing options...
jacko_162 Posted February 15, 2013 Share Posted February 15, 2013 change the form to <form method="post" action=""> what do you want the form to do? the following just checks if form is posted? echo $_SERVER['REQUEST_METHOD']; Quote Link to comment https://forums.phpfreaks.com/topic/274527-form-not-posting/#findComment-1412630 Share on other sites More sharing options...
TFT2012 Posted February 15, 2013 Share Posted February 15, 2013 However, when form.php loads, $_POST, $_GET, or $_REQUEST are all empty arrays. What could cause this? The form.php is re-directed from feedback.php. $_POST won't have data because the form action is "feedback.php", but not "form.php". Since you use session, you may save the $_POST in session variable, then read it on form.php. Quote Link to comment https://forums.phpfreaks.com/topic/274527-form-not-posting/#findComment-1412638 Share on other sites More sharing options...
TFT2012 Posted February 15, 2013 Share Posted February 15, 2013 the following just checks if form is posted? echo $_SERVER['REQUEST_METHOD']; Determine the if the method is "POST" or "GET" Quote Link to comment https://forums.phpfreaks.com/topic/274527-form-not-posting/#findComment-1412639 Share on other sites More sharing options...
Barand Posted February 15, 2013 Share Posted February 15, 2013 Only checked radio buttons (and checkboxes) are posted so $_POST['type'] will be empty if no selection is made Quote Link to comment https://forums.phpfreaks.com/topic/274527-form-not-posting/#findComment-1412641 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.