Re: IE/ IIS / PHP - Form posted twice in case of redirection

From: Date: Wed, 25 Jun 2008 13:31:52 +0000
Subject: Re: IE/ IIS / PHP - Form posted twice in case of redirection
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-28972@lists.php.net to get a copy of this message
Hello Dan, Thank you very much for your suggestion. There are workarounds but I am trying to find out why it is happening. I think not many use IIS and PHP for development or hosting and I was trying to find if anyone else too faced this problem and could find out why it was happening. Sukhwinder Singh ----- Original Message ----- From: "Dan Shirah" <mrsquash2@gmail.com> To: "Sukhwinder Singh" <ssruprai@hotmail.com> Cc: <php-windows@lists.php.net> Sent: Wednesday, June 25, 2008 6:11 PM Subject: Re: [PHP-WIN] IE/ IIS / PHP - Form posted twice in case of redirection
Sukhwinder,
I would suggest trying something simple like adding a variable to see if your page posted. Then, if it has run a simple Javascript function to redirect your page. <head> <script language="JavaScript"> <!-- function redirect() { location.replace(http://URL); } //--> </script> </head> <?php $redirect = $_POST['redirect']; if ($redirect == "Y") { ?> <body onload="redirect()"> <?php } else { ?> <body> <?php } ?> <form name="MyForm" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="hidden" name="redirect" value="Y"> <ALL YOUR OTHER FORM DATA HERE> <input type="submit" name="Submit" value="Submit"> </body> So, by default the value of $redirect will be "". Once you put data into your form and submit it, the value of $redirect will be "Y" in which case the Javascript function will be called and send you to your other page. Hopefully that helps. Dan


« previous php.windows (#28972) next »