megosh Posted April 9, 2010 Share Posted April 9, 2010 Hi, I've got a small problem that has been annoying me for a long while. In short, I've had a few pages that require the user to enter information and it creates an account for them... They work 99% of the time for all users... however, I do get some situations where users experience an inability to submit the page. Basically saying that hitting the submit button does nothing but refresh the page. This does not appear to be browser specific and can usually be solved by restarting the user's browser. (or in chrome opening a new tab) Here is some code from my creation page that has this problem. I edited out all the sql things and replaced it to keep it simple. I have personally experienced the problem stated in about 1 in 100~ tries. <html> <body> <?php if ($_POST['Submit']) { //do stuff echo "information entered: ".$_POST['test']; } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> Test: <input type="text" name="test"> <br> <input type='submit' name='Submit' value="Submit"> </form> <?php } ?> </body> </html> Does anyone have any possible insight into the cause of this problem, or what coding style I can adopt to prevent it from happening? All input is appreciated. Kind regards, Doug Quote Link to comment https://forums.phpfreaks.com/topic/198081-html-form-post-fails/ Share on other sites More sharing options...
haku Posted April 9, 2010 Share Posted April 9, 2010 Do you have any javascript on the page? Quote Link to comment https://forums.phpfreaks.com/topic/198081-html-form-post-fails/#findComment-1039339 Share on other sites More sharing options...
megosh Posted April 13, 2010 Author Share Posted April 13, 2010 There is: http://pastebin.com/bZtEWmeA which is used on every page for an expanding menu http://pastebin.com/mqCNreAC for an in-window popup (not called on any of my pages containing $_POST) http://pastebin.com/AnkbzqgX to replace the current in-window popup (not called on any of my pages containing $_POST) http://static.wowhead.com/widgets/power.js called on almost all pages Quote Link to comment https://forums.phpfreaks.com/topic/198081-html-form-post-fails/#findComment-1040711 Share on other sites More sharing options...
haku Posted April 13, 2010 Share Posted April 13, 2010 I thought it may be a javascript conflict, but I didn't see anything off-hand in your javascript files that looked like it would cause that problem. Sorry mate. Quote Link to comment https://forums.phpfreaks.com/topic/198081-html-form-post-fails/#findComment-1040773 Share on other sites More sharing options...
megosh Posted April 13, 2010 Author Share Posted April 13, 2010 I'm really at a loss... everything on my site that uses post is affected by it. Though a VB forum were running has no issues at all, so it can't be something weird with apache. Quote Link to comment https://forums.phpfreaks.com/topic/198081-html-form-post-fails/#findComment-1040783 Share on other sites More sharing options...
haku Posted April 13, 2010 Share Posted April 13, 2010 Run the script that generates the form, and then paste the HTML output for the form to here. Quote Link to comment https://forums.phpfreaks.com/topic/198081-html-form-post-fails/#findComment-1040785 Share on other sites More sharing options...
megosh Posted April 13, 2010 Author Share Posted April 13, 2010 I'm not entirely sure what you were asking, so I assumed this: <html> <body> <form action="/test.php" method="POST"> Test: <input type="text" name="test"> <br> <input type='submit' name='Submit' value="Submit"> </form> </body> </html> copy-paste from view-source:http://localhost/test.php Quote Link to comment https://forums.phpfreaks.com/topic/198081-html-form-post-fails/#findComment-1041147 Share on other sites More sharing options...
haku Posted April 14, 2010 Share Posted April 14, 2010 That looks ok there. Now show us the PHP code that processes the form. Quote Link to comment https://forums.phpfreaks.com/topic/198081-html-form-post-fails/#findComment-1041410 Share on other sites More sharing options...
megosh Posted April 14, 2010 Author Share Posted April 14, 2010 I'm not entirely sure what you mean... The code I posted in my first post is what processes the form. Quote Link to comment https://forums.phpfreaks.com/topic/198081-html-form-post-fails/#findComment-1041943 Share on other sites More sharing options...
haku Posted April 15, 2010 Share Posted April 15, 2010 Oops Try changing this: if ($_POST['Submit']) To this: if (isset($_POST)) And actually, I'm going to move this to the PHP forum. Your form looks to be properly structured HTML to me, so I'm thinking it's a PHP problem. That section of the forum is much busier than this one, so you are more likely to get the help you need there, though I will still check in to see what happens. Quote Link to comment https://forums.phpfreaks.com/topic/198081-html-form-post-fails/#findComment-1042123 Share on other sites More sharing options...
megosh Posted April 15, 2010 Author Share Posted April 15, 2010 Quick question... Doesn't if($_POST) do the same as if(isset($_POST))? What if I only want one portion of the post, if per-say I'm using multiple <input type='text' name='Test1'> <input type='text' name='Test2'>... Simply checking for if(isset($_POST)) wouldn't do what is required. Then what would the difference be between if(isset($_POST['Test1']) and if($_POST['Test1'])? I'm using both if(isset($_POST['test'])) and if($_POST['test']) in different places, and have experienced the problem with both. I'll try changing them all to isset() and will report back in a day or so. Thanks for the move and the attention. Quote Link to comment https://forums.phpfreaks.com/topic/198081-html-form-post-fails/#findComment-1042162 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.