The Little Guy Posted June 13, 2011 Share Posted June 13, 2011 on the php/MySQL side, what actions do you take from preventing double posting? Lets say a user fills out a form, then clicks the submit button. They wait and it takes 10 seconds and the didn't realize that it was still processing, so they click it again and finally the page reloads, but it added a duplicate record to the database. How do you go about handling this so if the user clicks the button 2+ times, it only adds one record unless they fill the form again. edit: Duplicate records are fine, but we want to prevent double posting I know there is a JS way, but not everyone has JS enabled. Quote Link to comment Share on other sites More sharing options...
fugix Posted June 13, 2011 Share Posted June 13, 2011 there is an interesting article that i found that uses javascript to handle this issue. http://myphpform.com/prevent-multiple-form-submissions.php Quote Link to comment Share on other sites More sharing options...
Philip Posted June 13, 2011 Share Posted June 13, 2011 Using a form token is probably the method IMO. See here for more info Quote Link to comment Share on other sites More sharing options...
fugix Posted June 13, 2011 Share Posted June 13, 2011 Using a form token is probably the method IMO. See here for more info one of the users on that site poses a good point of javascript being disabled, not a big fan of using js for much, just found the article interesting how they did it, OP I would go with kingphillip's method as well Quote Link to comment Share on other sites More sharing options...
Philip Posted June 13, 2011 Share Posted June 13, 2011 Yup, the form token is immune to JS being disabled. According to Adobe SiteCatalyst, ~8.3% of users have JS disabled. Quote Link to comment Share on other sites More sharing options...
fugix Posted June 13, 2011 Share Posted June 13, 2011 Yup, the form token is immune to JS being disabled. According to Adobe SiteCatalyst, ~8.3% of users have JS disabled. a scary statistic really. Quote Link to comment Share on other sites More sharing options...
proggR Posted June 13, 2011 Share Posted June 13, 2011 I had always heard people say to use a form token and didn't know how to do it and for some reason never looked it up. I always assumed it would be more complicated but that is actually the easiest thing I've ever seen. I wasted so much time comparing the data being posted to existing data to check for a double submit that way. Thanks for the link KingPhillip. Being lazy is hard work. 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.