Forum Moderators: coopster

Message Too Old, No Replies

No warning for going back to a POSTED page

After pressing the back button, going to a page with posted variables

         

ryan_b83

4:07 pm on Aug 18, 2006 (gmt 0)

10+ Year Member



Hi i am wondering, how can i stop the browser from warning the user that "Post Data" will be resubmitted... For example, on goolge you do a search, then click on a link, then clikc the BACK button in your browser, it dosn't give you the warning that you are going back to a page with posted variables?

Any ideas?

Thanks!

stajer

4:17 pm on Aug 18, 2006 (gmt 0)

10+ Year Member



instead of doing a method=post, do a method=get so the variables get transfered in the url.

vincevincevince

4:28 pm on Aug 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



stajer is right - GET will avoid the problem, but since you asked about POST I assume you like the fact you don't get enormous URLs with data and passwords publically visible...

One option to make it look pretty-much exactly like POST and work in almost the same way, but without the warnings.

Use GET but immediately read the GET array into a session variable and redirect to a page with no arguments in the URL:
i.e.


form.php -> <form method="GET" action="do.php"> blah blah...
do.php -> $_SESSION[gets]=$_GET; header("Location: show.php");
show.php -> $_POST=$_SESSION[gets];

In the example above, form.php will be submitted by GET, but the URL will never be visible (or if it is, not for more than a split second), the browser forwarding immediately to show.php with no arguments in the URL. Show.php will have the original $_GET array assigned to $_POST for you to use as usual.

Pressing 'back' from a page linked from show.php in this situation will go back to show.php (no warnings), if you press back from show.php you go straight to form.php (browsers skip the header-redirection from the history list)

The three parts can be all included into one script, or split in any way you want. I had them as separate files just to make it clearer.

ryan_b83

4:39 pm on Aug 18, 2006 (gmt 0)

10+ Year Member



great thanx guys...

stajer

5:18 pm on Aug 18, 2006 (gmt 0)

10+ Year Member



Good idea vince. Also, you can us js to rewrite the browsers history cache to skip the middle page when pushing BACK. I don't remember exactly how to do this, but google for it.