Inside Technique : Multiple Form Posts
This month, we are hard at work updating InsideDHTML to add many new community features. As part of this update (we should have a beta ready in January, 1999), we are going to be using HTML input forms throughout the site. As a part of our early testing we quickly ran into the form refresh issue. This is where a user refreshes a page after they submit the form or they hit the submit button multiple times. These actions cause the sam eform to be submitted multiple times, causing multiple entries in our database. In our scenarios these entries clutter the system rather than cause any real harm. However, in an e-commerce site, multiple submissions can mean multiple orders. In all cases, preventing the same form from being submitted is a very important and necessary feature.
To solve this problem we came up with a fairly simple solution. With every form we create, we add a simple hidden timestamp field based on the current time. When the form is submitted, if this time stamp equals the time stamp of the last submission, we ignore the new submission.
This solution solves the problem with resubmitting the same form or a user hitting the submit button multiple times. This solution does not help with form submissions prior to the last submission. For example, if the user backs up in the history and then refreshes and resubmits an older form, the results will be stored.
Another alternative is to never allow submissions if the last submission timestamp is after any form submission. We chose not to do this because it may prohibit the submission of a unused form from the user's history.
On the next page, we show you our ASP code fragments for adding and checking the time stamp. While this approach solves our problem, we are sure there are many other solutions that are equally effective. If you have other ideas on how to do this detection, please share them with us in our Server discussion forum (our current forums do not yet implement this test so please don't try submitting the same message over and over :-).
Page 1:Multiple Form Posts
© 1997-2000 InsideDHTML.com, LLC. All rights reserved.