Right. I store mine in the same db, and it gets inserted with the other data
from the form. Before inserting, the script does a quick query, selecting
all rows where the unique_id is equal to the current ID. since a new one is
generated for each submit click, the answer will be zero on a proper insert.
On a reload, the answer (mysql_affected_rows) will be 1, so you exit the
script at that point. I also check to make sure the required fields are not
blank before inserting, so that handles the problem of inserting a blank
record if the user clicks twice.

anyway, it works... you can click and click and click all you want, reload
until you're blue in the face, and you'll only get one proper insert. better
yet, not a word of javascript was involved. :)

"Jonathan Hilgeman" <[EMAIL PROTECTED]> wrote in message
> This is another good idea. When reloading the page, have the script
> that unique ID, store it in a separate table AND  put it in a hidden
> When the user submits, the database checks to see if the unique ID is in
> database, and if so, the ID is deleted from the database, and the order is
> processed. On subsequent clicks, the unique ID would not be found in that
> database table so the query would fail with a message ("You have clicked
> more than once") or something like that, and the person could check the
> status of an order identified by that unique ID.
> - Jonathan
> -----Original Message-----
> From: Aron Pilhofer [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 04, 2002 9:51 AM
> Subject: Re: [PHP-DB] Tutorial?
> The easiest and best solution is to redirect to a new page after the
> But I have had cases where it was necessary to have the submit code and
> form on the same page.
> I agree totally with jonathan that a server-side solution is the way to
> To solve the problem (avoid clicking twice and/or reloading the page) I
> a hidden field that generated a unique ID based, and then placed that into
> field that only accepts unique values. If the user reloads, the query
> fails - trap that error and you're golden.
> "Jonathan Hilgeman" <[EMAIL PROTECTED]> wrote in message
> > Hi Jennifer,
> > I'm guessing the purpose of this would be to keep people from
> > double-clicking and submitted information twice, possibly making an
> > application deduct payment twice or something important similar in
> >
> > The best way I've found of accomplishing the goal of keeping people from
> > clicking twice has three parts:
> > 1) Quickly switching the page. On the next page, have PHP write out
> > 300 spaces and a newline, then call the flush() function to make the
> output
> > get sent to the browser. In many cases, this will cause the browser to
> > quickly switch to the next page and display a blank page while the data
> gets
> > processed.
> >
> > 2) It's still remotely possibly to click twice even if you have part 1
> > place, so this is a more fool-proof method. Store your data in a
> > before processing it - along with a timestamp. When the person clicks
> > submit button twice, the program checks the database to see if there is
> the
> > same information with a very close timestamp. If so, update the
> in
> > the database. At this point you can choose 3 paths:
> >
> > - Store the data so you can batch-process the data at a later time, once
> you
> > are sure that the visitor has left and there will be no more clicks. For
> > example, have a program that runs every 5 minutes (via cron), then have
> that
> > program check for data/orders that are at least 5 minutes old, and
> > them. That means that the timestamp hasn't been updated by extra clicks
> 5
> > minutes (and you could still have notified the visitor that their order
> > data request is now in line to be processed).
> >
> > - Process the data immediately. If you need to process an order
> immediately
> > and give back results, use the above method, but modify it a bit.
> of
> > just displaying notification that their order is in line to be
> > you can submit to another PHP program which sleeps for about 3-4
> > then checks the database until there are no clicks for at least 4
> > and THEN processes the data, and returns a value to the screen in like
> > seconds. Both of these methods have similar goals, though - Receive data
> and
> > timestamp it, Wait $Time, Check for timestamp updates, Process when
> > timestamp is $Time old.
> >
> > 3) Have a very visible notice that people should not click multiple
> > or else undesirable results may occur, and we want "your" request/order
> > be perfect. Emphasize the request to click only once and to be patient,
> and
> > if something goes wrong, here's how to contact us.
> >
> > - Jonathan
> >
> > -----Original Message-----
> > From: Jennifer Downey [mailto:[EMAIL PROTECTED]]
> > Sent: Saturday, March 02, 2002 10:18 PM
> > Subject: [PHP-DB] Tutorial?
> >
> >
> > Hi all,
> >
> > Can anyone point me to a good tutorial on how to disable a submit button
> > once clicked?
> > preferably in php.
> >
> > Thanks
> > Jennifer Downey
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to