> A tactic I've been planning to use, but don't know if it actually works or
> not, is to disable the button first thing in its onClick so the second
click
> occurs on a disabled button.  Does anybody know if this actually works or
> not?
>
> - Theo

How do you determine if the click is the first time, when user send form,
decide to go back to previous page using browser's back button? It's
impossible to determine the click is the first or not using JavaScript.
(It's only works browser does not send form data immediately and it allow
users to send form data while it is sending form data or waiting response
from server. Is this what you want to prevent? Then it works.)

John's uses hash to compare posted values are the same as in DB, it works.
In many cases, it may be a preferred way. If you are just worried about
sending form data multiple times using browser's back button, you can do as
follows using session var.

switch ($task) {
  case 'update':
    if ($HTTP_SESSION_VAR['FORM_DATA_SENT']==false) {
         // do update
    }
    $HTTP_SESSION_VAR['FORM_DATA_SENT'] = true;
    break;
  case 'show_form':
    $HTTP_SESSION_VAR['FORM_DATA_SENT'] = false;
     // show form
    break;
}

Regards,

Yasuo Ohgaki

>
> -----Original Message-----
> From: John Huggins [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 28, 2001 3:04 PM
> To: Manuel Lemos; [EMAIL PROTECTED]
> Subject: RE: [PHP] Double Click
>
>
> If you are lucky and are feeding this form data to a database, you can
> create a unique hash field from other fields that would not change from
> click 1 to click 2.  Then just make the database treat the hash as a
unique
> index and it should prevent double entries.  Works for me.
>
> Other advice is to not tell the double clicker that had an error; Just
> silently ignore their second request.
>
> > -----Original Message-----
> > From: Manuel Lemos [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, February 28, 2001 2:55 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [PHP] Double Click
> >
> >
> > Hello Fabian,
> >
> > On 28-Feb-01 03:01:02, you wrote:
> >
> >
> > >Hi,
> >
> > >I have a page, and when I have to add a product I use a form,
> > many people are
> > >used to make double click in every task, so when the product is
> > sent with a
> > >double click in the send button, the program send it twice to
> > the data base.
> >
> > >What can I do to prevent this?
> >
> > You may want to try this forms generation class that lets you define a
> > warning message that shows when the user attempts to submit a form more
> > than once.
> >
> > http://phpclasses.UpperDesign.com/browse.html/package/1
> >
> > Regards,
> > Manuel Lemos
> >
> > Web Programming Components using PHP Classes.
> > Look at: http://phpclasses.UpperDesign.com/?[EMAIL PROTECTED]
> > --
> > E-mail: [EMAIL PROTECTED]
> > URL: http://www.mlemos.e-na.net/
> > PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
> > --
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to