Emptying $_POST?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

    I use a POST variable named "status" to show different screens while
keeping everything in the same script.

The problem is that in the Print screen, I need to empty this variable
so the user doesn't get FireFox's familiar ""The page you are trying
to view contains POSTDATA" if he hits F5/Refresh.

Neither unset() nor setting the variable to nothing works:

    switch ($_POST['status']) {
            //Main screen
            echo "<form method=post><input type=submit name=status
        case "Print":
            //SELECT, etc.
            //To avoid FireFox's "The page you are trying to view contains
POSTDATA" if user hits F5

            //Doesn't work unset($_POST['status']);
            //Doesn't work $_POST['status']="";

Is there a way to remove this variable or set it to nothing, so that
the user is redirected to default, main screen?

Thank you.

Re: Emptying $_POST?


Quoted text here. Click to load it

Default flow for emptying POST/not having to deal with 'send postdata  =

again?' messages:

1. Set up the form to post to a script almost solely dedicated to proces=
s  =

that (or also other) forms.
2. Process the form, do actions, perhaps store some data in a session.
3. Instead of output/a page, send the user a header() redirect  =

(header('Location: http://example.com/thankyou ') for instance.
4. The UA/browser of the user goes to the page desired, with a GET  =

request, so will receive no prompt on reload. Possibly show some variabl=
es  =

 from the session if the user has to be informed of something/has reques=
ted  =

custom data.
-- =

Rik Wasmus

Re: Emptying $_POST?

On Tue, 12 Feb 2008 12:47:10 +0100, "Rik Wasmus"
Quoted text here. Click to load it

Thanks for the tip, but apparently, there's no way to use POST to pass
data (I'd rather keep the URL clean of any variable). Header() will
return the user to the main page. And I'd prefer to keep all the code
in a single file/page, hence the use of "status" to know where I am.

Too bad, but it was just a minor thing. I asked just in case there
were a way to keep the user in the Print page while removing FFox's


Re: Emptying $_POST?


Quoted text here. Click to load it

It is perfectly possible, just start a session, store variables in it on a  
post, display (and possibly unset session variables) depending on  
variables available in the session. There's no good reason a page can't  
redirect to itself.
Rik Wasmus

Site Timeline