MySQL Forums
Forum List  »  Newbie

Re: Unwanted multiple inserts: Should I use insert or replace into?
Posted by: Rick James
Date: October 23, 2010 12:59AM

How about this? (You may have to get CF to do the work for you; sloppy of them not to have a solution.)

First, let me get the problem straight...
You have a page where the user fills in some info and presses a button to Submit it to a database? And there is currently nothing to prevent an impatient user from pressing the button twice?

A solution (one of many)...
When building the page, add a type=hidden field in the <form>. The value= is some unique number (perhaps an AUTO_INCREMENT, perhaps a guid, ...). Then, when the user submits the query, first you verify that that number has not been seen before. If not, you proceed to do the INSERT (or REPLACE, or whatever).

That way, an extra press will be ignored.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.