[英]PHP redirect doesn't work on IE?
I try to put script to send an email and redirect to main page. 我尝试将脚本发送电子邮件并重定向到主页。 yes, it's work!
是的,它的工作! but...
但...
On IE, it doesn't work. 在IE上,它不起作用。
code example: 代码示例:
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
//$email_to1 = "a@abc.com";
$email_to2 = "b@abc.com";
$email_subject = "Email from www.abc.com";
................
................
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
//@mail($email_to1, $email_subject, $email_message, $headers);
@mail($email_to2, $email_subject, $email_message, $headers);
header("Refresh: 3; http://www.abc.com/Contact.html");
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.<br>
<a href="http://www.abc.com/Contact.html">back to website</a>
<?php
}
?>
How could i solve it? 我怎么能解决它?
Please use below code 请使用以下代码
header('Location:http://www.abc.com/Contact.html')
exit;
Use this code instead 请改用此代码
die(header('Location:http://www.abc.com/Contact.html'));
You can omit die()
, but is useful here, because using it allows to prevent script running after sending redirect header. 您可以省略
die()
,但在此处很有用,因为使用它可以防止脚本在发送重定向标头后运行。
Change 更改
header("Refresh: 3; http://www.abc.com/Contact.html");
into 成
header("Refresh: 3; URL=http://www.abc.com/Contact.html");
I think that should do the trick 我认为应该这样做
Also take note of this answer: 'Refresh' HTTP header and this comment: 'Refresh' HTTP header 另请注意以下答案: '刷新'HTTP标头和此注释: '刷新'HTTP标头
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.