I've also seen something similar implemented using javascript (i guess -
never looked into it in any detail)

The online bank I use does this. Basically, when I click a submit button,
the button is replaced by an image (like a greyed out submit button) which
has the caption Submitted. Clicking this does nothing.

Like I say, I'm 99.9% positive this is implemented using javascript, but
have never investigated how it works...

Richy


==========================================
Richard Black
Systems Programmer, DataVisibility Ltd - http://www.datavisibility.com
Tel: 0141 435 3504
Email: [EMAIL PROTECTED]


-----Original Message-----
From: Jonathan Hilgeman [mailto:[EMAIL PROTECTED]]
Sent: 04 March 2002 16:40
To: 'Jennifer Downey'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Tutorial?


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 nature.

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 about
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 in
place, so this is a more fool-proof method. Store your data in a database
before processing it - along with a timestamp. When the person clicks the
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 timestamp 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 process
them. That means that the timestamp hasn't been updated by extra clicks in 5
minutes (and you could still have notified the visitor that their order or
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. Instead of
just displaying notification that their order is in line to be processed,
you can submit to another PHP program which sleeps for about 3-4 seconds,
then checks the database until there are no clicks for at least 4 seconds,
and THEN processes the data, and returns a value to the screen in like 4-5
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 times,
or else undesirable results may occur, and we want "your" request/order to
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
To: [EMAIL PROTECTED]
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