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? Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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.