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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
To: "Sukhwinder Singh" <ssruprai@xxxxxxxxxxx>
Cc: <php-windows@xxxxxxxxxxxxx>
Sent: Wednesday, June 25, 2008 6:11 PM
Subject: Re: 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



--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux