我无法使用ECHO方法将访问者发送到感谢页面。请帮助!
<?php
}
else
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
if (($name=="")||($email==""))
{
echo "All fields are required, please fill <a href='"'">THE FORM</a> again.";
}
else{
$from="From: $name<$email>'r'nReturn-path: $email";
$subject="Subscription Request from Website";
mail("test@test.com", $subject, $message, $from);
echo "Location: thankyou-subscription.php";
}
}
?>
请使用header
函数重定向用户
的例子:
header("Location: thankyou-subscription.php");
你也应该在echo "All fields are ..."
之后exit
echo
不重定向,除非它输出一些JavaScript代码或HTML元刷新。如果你只通过PHP重定向,使用header
,并确保在header
之前没有发送任何内容到浏览器,甚至没有空行
echo "Location: thankyou-subscription.php";
应该header("Location: thankyou-subscription.php");
编辑
既然你提到在重定向之前不能避免echo,你可以使用JavaScript,因为PHP重定向在输出后不起作用。你可以做
echo "<script>location.href='thankyou-subscription.php';</script>";
不要回显,而是这样做:
header("Location: thankyou-subscription.php)";