Page 1 of 1

unset $_POST

Posted: Tue Dec 09, 2008 7:22 am
by aceconcepts
Hi All,

Using POST values are obviously submitted to the PHP engine and processed by a script. When you refresh the browser immediately after a POST it asks you whether you want to resend the POST data.

Now, is there a way to "unset" the POST request after it has been sent?

Thanks.

Re: unset $_POST

Posted: Tue Dec 09, 2008 7:25 am
by papa
It doesn't work unsetting the variable?

Re: unset $_POST

Posted: Tue Dec 09, 2008 8:03 am
by aceconcepts
I'm talking about erasing the complete POST array.

However, I'm rather doubtful it can be done - after all it is a method.

Re: unset $_POST

Posted: Tue Dec 09, 2008 8:12 am
by Eran
The pattern I use most of the time is to redirect from the page that received the post request if it is successful (action completed). If you stay in the request (a redirect is a new request), there is no way to avoid resending the POST data on refresh.

Re: unset $_POST

Posted: Tue Dec 09, 2008 8:18 am
by papa
Ok I see what you mean, sorry.

Re: unset $_POST

Posted: Tue Dec 09, 2008 8:22 am
by aceconcepts
No worries Papa, i should have explained myself more clearly :D

Yes, I've had re-directs at the back of my mind. Was just wondering if there was an alternative.

Anyhow, thanks for the responses :wink:

Re: unset $_POST

Posted: Tue Dec 09, 2008 2:52 pm
by Syntac
Redirecting via header() eliminates the refresh warning.