Robert's solution is a good one because some people might not have
javascript enabled, or their browser might malfunction if they are
using a buggy one (happens alot more than you'd think), or if they
have spyware or a virus.  When you protect it server side, you have
alot more control over things.

You might try implementing both solutions so that you are well
protected from the server side checks while your user understands
visually that their order is being processed when the button
disapears.   Or you could disable it instead of making it go away
completely and make it say "Processing..." like this:

<input type=button value="Click Me"
onclick="this.disabled='true';this.value='Processing...';">

On 2/10/07, Robert Garcia <[EMAIL PROTECTED]> wrote:
javascript not allowing second click is one way....

Another, is don't use a autoincremented integer as the unique key of
the order, or get it from the DB, before you insert. So if in your
process, you ASSIGN a order id, and store as a user var, before
inserting order, then on submit, if submit second time, it will fail
due to unique id contraints.

An easy way to do this, is before submitting order, earlier in the
process, make an order, by inserting a bit of info, and have a field,
called COMPLETE as boolean. on the first submit, make sure you set
complete = false. Now you have a ready order in the db, and an order
id, even if you use autoincrement. on the final submit, UPDATE that
order, and set complete to Y.

There are other ways to skin it, but 2 step order like this is pretty
damn foolproof. I have a couple of sites that take millions of
dollars of orders, one, 2 million a day at times, and have never seen
a dupe, because of a variant of the above method. But in my early
days, it happened enough to piss me off. ;-)

Just remember to have a process, at the end of each month or so, to
purge incomplete orders.

HTH

--

Robert Garcia
President - BigHead Technology
VP Application Development - eventpix.com
13653 West Park Dr
Magalia, Ca 95954
ph: 530.645.4040 x222 fax: 530.645.4040
[EMAIL PROTECTED] - [EMAIL PROTECTED]
http://bighead.net/ - http://eventpix.com/

On Feb 10, 2007, at 11:13 AM, Dan Stein wrote:

> I have a very complicated taf that is used to process the orders on my
> clients site.
>
> I guess we have been lucky so far. But seems like last month at
> least one
> person hit the submit button twice looks like they might have even
> found a
> way to do it before the page refreshed.
>
> It made a duplicate order record and made a mess of the second
> order so it
> was actually everything twice.
>
> I have not figured out how that could happen yet.
>
> But what is the best way to prevent the submit button from getting
> hit twice
> if in fact they are going to do it even before page refreshes.
>
> Of note there are at least 3 different forms on this page.
>
>
> --
> Dan Stein
> FileMaker 7 Certified Developer
> Digital Software Solutions
> 799 Evergreen Circle
> Telford PA 18969
> Land: 215-799-0192
> Cell: 610-256-2843
> Fax 215-799-0192 ( Call 1st)
> FMP, WiTango, EDI,SQL 2000, MySQL, CWP
> [EMAIL PROTECTED]
> www.dss-db.com
>
> Men do not care how nobly they live, but only how long they live,
> although
> it is within the reach of every man to live nobly, but within no
> man's power
> to live long.  Brian Haig Private Sector
>
>
>
> ______________________________________________________________________
> __
> TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
>
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf


________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

Reply via email to