homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Dealing with multiple form submits
what are the best ways to deal with multiple form submits using php?

10+ Year Member

Msg#: 3294819 posted 10:25 pm on Mar 27, 2007 (gmt 0)

I have implemented javascript code to try and block multiple form submissions on many of my pages but if users have javascript disabled this does no good. I have brainstormed and come up with some different methods to implement a server-side solution to the problem and I am curious to know what everyone else is doing to prevent these duplicate submissions by careless/impatient users.

How do you handle the multiple form submit problem?



5+ Year Member

Msg#: 3294819 posted 11:21 pm on Mar 27, 2007 (gmt 0)

Disable post button with javascript after clicked once.

Should be some server-side logic if javascript is not supported. Like ignoring posts from the same ip (maybe check via cookie) if NNN seconds have not passed yet from the last post.


WebmasterWorld Senior Member eelixduppy us a WebmasterWorld Top Contributor of All Time 5+ Year Member

Msg#: 3294819 posted 11:34 pm on Mar 27, 2007 (gmt 0)

Many times a resubmit is due to a page refresh of the action page, where the information is submitted again. If you redirect the action page somewhere else, you can eliminate this cause significantly.


10+ Year Member

Msg#: 3294819 posted 2:06 pm on Mar 29, 2007 (gmt 0)

I do use javascript to disable the submit button but not all users have javascript enabled so I need a server-side solution as well. Also, I already redirect all form action pages so they can not be refreshed. Once again, I am not looking for a javascript solution here as it only helps the problem but cannot solve it 100%.

The problem I am seeing is with forms that take a bit of processing so they take around 10 seconds to process and complete all the needed actions before sending the user to the success/failure page. On these forms the user may get impatient and click the submit button again causing the data to be submitted twice.

The solution to the problem in my mind is fairly complex as it involves creating an md5 hash on the values in the form that should always be unique and saving that hash in the user's session so that if they try to submit the same form again during their session it will block the second submit. This allows the user to still use their browser's back button to get back to the form and they can modify the fields and submit the form again with the new values. As long as the new values are unique then their md5 hash will be different and the submit will work fine.

Does anyone see any problems with this approach or perhaps a better/simpler/easier way to accomplish the same thing?

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved