|  | Posted by Rik on 08/21/06 10:57 
Vash wrote:> Juliette wrote:
 >> alex.alexander@gmail.com wrote:
 >>> I've been searching for a way to prevent that STUPID re-post warning
 >>> message from showing up when you hit the refresh button on your
 >>> browser...
 >>>
 >>> I finally found a good solution that does not require redirection,
 >>> extra pages, etc. etc.
 >>>
 >>> Just run the following commands at the end of your post-processing
 >>> php file:
 >>>
 >>> foreach ($_POST as $var => $value) {
 >>> unset($var);
 >>> }
 >>>
 >>> This way you'll never have re-posting issues and you'll get rid of
 >>> the stupid warning message! :D
 >>>
 >>
 >> Except that your solution will not work as you are only unsetting the
 >> local variable $var.
 >>
 >> However the following should work:
 >>
 >> unset( $_POST);
 >>
 >> or:
 >>
 >> foreach( $_POST as $var => $value) {
 >> unset( $_POST[$var] );
 >> }
 > Well, it's strange. I used this method to prevent the message from
 > popping up when I posted data through the httprequest object and then
 > hit F5 and it worked.
 >
 > However, when I try it on a simple page with a simple form it does not
 > work (nor my original code or your modified one).
 >
 > I'll check it out and get back to you.
 >
 > Alex
 
 Well, I'd be flabbergasted when this method actually worked.
 Some insight: if the user hits the back button, and goes back to a page
 where he arrived using a POST, and the browser does indeed request the page
 again, instead of getting it form it's cache, POST values are send with the
 HTTP request again. So the $_POST array will be populated, the script will
 work as it did before.
 
 The method mentioned here is utterly useless IMO.
 
 Grtz,
 --
 Rik Wasmus
 [Back to original message] |