|
-
November 15th, 2004, 02:48 PM
#1
Can I clear $_POST superglobal?
Hi
I wonder whether there is a way to clear the $_POST superglobal array or even set an array element to a new value.
I've got a self-referencing form where the user can enter some text and that is calling itself. I decide whether the page was initially displayed by something like this:
Code:
if ( (isset($_POST["Submit"]) == TRUE) && ($_POST["Submit"] = 'Say') )
But once the user has submitted the form, $_POST["Submit"] will still be set when the page is reloaded (without pressing the submit button).
Is there a straigtforward way to clear or somehow modify the superglobal to prevent resubmit on reload? As you might expect, unset($_POST["Submit"]) or $_POST["Submit"]='none' does not work...
Thank you in advance
Oliver.
-
November 16th, 2004, 01:19 AM
#2
Re: Can I clear $_POST superglobal?
If I am understanding you correctly, you seem to think that the $_post variable stays the same through several http requests, because it stays on the server. I can assure you this is incorrect, the $_post variable always holds the http post variables from the current http request.
The reason you are seeing the same value again after a reload, is most likely that the browser repeats the same http request that was used to load the page (in this case the submit from the previous page).
The biggest problem encountered while trying to design a system that was completely foolproof,
was, that people tended to underestimate the ingenuity of complete fools.
Douglas Adams
-
November 16th, 2004, 01:32 AM
#3
Re: Can I clear $_POST superglobal?
It'd be better to use $_SESSION's variable for what you want (if I understand correctly)
-
November 19th, 2004, 04:45 PM
#4
Re: Can I clear $_POST superglobal?
i think you are reffering to the fact that some users hit the refresh button and it tries to repost the data again to page. its a common problem with blogs that refresh to the same page..... if you want to make it so that when they hit the refresh key after posting something just redirect them to that page after you have done the neccessary code.
like either with
<code here>
header( "Location: http://pageyouwanthere" );
or make a page after the post that they click a link on to get back to the page you want them to be at.
quite like many forums do.
-
November 20th, 2004, 09:14 AM
#5
Re: Can I clear $_POST superglobal?
unset() $_POST['Submit'] and then use header(), that should work.
Also change:
(isset($_POST["Submit"]) == TRUE)
to
(isset($_POST["Submit"]))
Last edited by Danii; November 20th, 2004 at 09:19 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|