Dingbats Posted November 30, 2009 Share Posted November 30, 2009 I have this form: <form action="index.php?loc=buy" method="POST"> <p><input type="text" id="email" value="Your e-mail address" /> <textarea id="message">What do you want?</textarea> <input type="hidden" id="submitcheck" value="1" /> <input type="submit" id="submit" value="Send" /></p> </form> At the top of the file, I'm checking to see if anything's been posted, I've tried both if (isset($_POST["submitcheck"])) and if (array_key_exists("submitcheck", $_POST)). Both always return false. var_dump($_POST) returns "array(0) { }". From a quick Google search I get the impression that this is probably some kind of problem with the configuration, and not the code. However, I'm completely lost when it comes to fixing it. I should mention that GET works fine. Any ideas? Link to comment https://forums.phpfreaks.com/topic/183429-_post-is-empty-and-refuses-to-be-anything-else/ Share on other sites More sharing options...
aeroswat Posted November 30, 2009 Share Posted November 30, 2009 what is submitcheck? I think you meant to put submit there... As far as I know the name of the POST variable is always the name of the form element id EDIT: Why are you using a hidden field? Link to comment https://forums.phpfreaks.com/topic/183429-_post-is-empty-and-refuses-to-be-anything-else/#findComment-968189 Share on other sites More sharing options...
mrMarcus Posted November 30, 2009 Share Posted November 30, 2009 you need to add a name="" to your input fields, as that's what the $_POST superglobal checks for: <form action="index.php?loc=buy" method="POST"> <p><input type="text" name="email" id="email" value="Your e-mail address" /> <textarea name="message" id="message">What do you want?</textarea> <input type="hidden" name="submitcheck" id="submitcheck" value="1" /> <input type="submit" name="submit" id="submit" value="Send" /></p> </form> EDIT: you can lose the id="" from each input, unless you are using them for another reason. they will not work for what you are trying to do though. Link to comment https://forums.phpfreaks.com/topic/183429-_post-is-empty-and-refuses-to-be-anything-else/#findComment-968193 Share on other sites More sharing options...
Dingbats Posted November 30, 2009 Author Share Posted November 30, 2009 Thanks for your quick replies. I had tried (I just didn't mention it for brevity) checking for $_POST["submit"] and using name instead of id, but it never worked. Now, for some totally inexplicable reason, when I tried exactly the same thing again, it works. I'm amazed and confused. Thanks again, consider this solved. Link to comment https://forums.phpfreaks.com/topic/183429-_post-is-empty-and-refuses-to-be-anything-else/#findComment-968200 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.