RE: Re[5]: [PHP-WIN] Preventing multiple submits
| From: | James Duncan | Date: | Fri, 25 Aug 2000 15:57:38 +0000 |
| Subject: | RE: Re[5]: [PHP-WIN] Preventing multiple submits | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-2155@lists.php.net to get a copy of this message | ||
Folks,
Please ignore my previous email about my feeble attempts to track the
multiple submitting of a form using PHP. I have accomplished this via
writing a variable to a text file and then reading this in each time and
incrementing it, etc. If the value is greater than 1 then the form has
already been submitted. I can check for this value each time my PHP script
runs and perform the necessary action depending on the value.
Of course this is only a temporary solution because it only works in a
single user environment. I need to look at sessions and "session_register"
in particular it seems! Do the "session" features require that the client
can accept cookies? For example, if cookies are disabled on the client do
"sessions" still work? Are they server-side only? The whole point of this
exercise is to find a server side only solution to preventing a user
submitting the same form multiple times.
However, I already have the same problem as Pablo, in that the browser only
displays the output from the last script ran, which if the user hits the
submit button more than once is a message saying "You have already submitted
this form" rather than the intended message of "Email has been successfully
sent".
Is there an easy way to get PHP to immediately clear the screen at the start
of a script, without waiting for the rest of the script to finish
processing? If so then I can clear the screen immediately after the user
clicks the submit button, which would prevent the user from going mad with
the submit button!
Thanks
James
-----Original Message-----
From: Pablo Vera [mailto:pvz@vercan.com]
Sent: 25 August 2000 15:40
To: Zak Greant
Cc: James Duncan; php-windows@lists.php.net
Subject: Re[5]: [PHP-WIN] Preventing multiple submits
Zak:
You are COMPLETELY RIGHT !, I did some checking and by registering a
variable (with session_register), it will keep its value from script
to script. I only have one problem, when the user submitts a second
form, the browser will cancel the first connection. The first script
will run normally, but its output (confirmation, error, etc.) will not
reach the browser. The user will only see whatever the second script
sends. If there was an error in the first one, he won't know. How do
you solve this ?
Saludos,
Pablo Vera
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Thursday, August 24, 2000, 5:22:08 PM, you wrote:
ZG> At 05:11 PM 8/24/00 -0500, Pablo Vera wrote:
>>[snip]
>>Zak:
>>
>>I think that the "if (! $post_counter)" will always result in a true
>>condition, this is because the only ways to preserve a variable from
>>instance to instance of a script is by sending them in the URL or by
>>setting a cookie, but since the form is being submitted twice from
>>exactly the same page, you will have two scripts running at the same
>>time, with exactly the same variables and values, and the output of
>>the first one will not be received by the browser, because the second
>>one canceled that connection. You will end up processing two forms,
>>but the user will receive confirmation for only one.
ZG> The $post_counter variable is not stored client side. All that you
store
ZG> client side is a session id in either a cookie or as get/post data.
ZG> The $post_counter variable is tracked server side by PHP's session
manager.
ZG> (You could also use another mechanism, if desired.)
ZG> - zak