我尝试使用脚本发送电子邮件并重定向到主页。是的,它的工作!但...
在IE上,它不起作用。
代码示例:
<?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
}
?>
我怎么能解决它?
答案 0 :(得分:2)
请使用以下代码
header('Location:http://www.abc.com/Contact.html')
exit;
答案 1 :(得分:0)
请改用此代码
die(header('Location:http://www.abc.com/Contact.html'));
您可以省略die()
,但在此处很有用,因为使用它可以防止脚本在发送重定向标头后运行。
答案 2 :(得分:0)
更改
header("Refresh: 3; http://www.abc.com/Contact.html");
到
header("Refresh: 3; URL=http://www.abc.com/Contact.html");
我认为应该做的伎俩
另请注意以下答案:'Refresh' HTTP header和此评论:'Refresh' HTTP header