|
Posted by Shelly on 11/14/06 04:12
"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:EJSdnWsIGMcLqcTYnZ2dnUVZ_r-dnZ2d@comcast.com...
> Shelly wrote:
>> I have the following for a test of the submit button being pressed:
>>
>> if (isset($_POST['theSubmitButton'])) {
>>
>> This works fine and I have been doing this for a long time. Here is the
>> question:
>>
>> If I do a submit and have it come back to the same page, all is fine. If
>> I now click the browser refresh button, I get another submittal. How do
>> I "unset" the status so that it doesn't think I clicked the submit button
>> when I click the refresh button?
>>
>> Shelly
>>
>>
>
> You can't just unset a $_POST variable (well, you can, but it won't work
> like you want). When your user hits reload on the browser, the browser
> will resend the post, setting it again.
>
> You can, for instance, have the submit button go to another page to
> process the data, then redirect back to your original page with a header()
> call.
I already tried something like this just after I submitted the original
post. I had the original submit button force the processing of the post and
at the end of that processing it was sent to another page, pageRedir.php,
via a header. In pageRedir.php I had it go immediately via a header back to
the original page. A refresh of that original page then still resulted in
another processing.
Anyway, a refresh would still satisfy the isset for the submit button so it
would still be sent to another page. I don't see how this gains anything.
>
> You can also set a value in the $_SESSION to indicate the page was
> submitted; you just need to ensure you have a way of unsetting it once
> they leave that page.
I thought of this too, but didn't see how I could guarantee an unsetting of
the session variable. There are so many ways to leave a page :-). So, I
abandoned this line of thought.
> There are other ways - but these are the two I use most often.
Navigation:
[Reply to this message]
|