可能我遗漏了一些简单的东西,但我正在尝试做的是完成一份注册表,并在它发送确认电子邮件后,将其重定向到另一个页面。到目前为止,我所拥有的
if($sentmail){
<redirection code>
}
else {
echo "Problem sending information, please resubmit.";
}发布于 2011-10-23 09:56:10
您希望header()停止处理,也可能希望exit停止处理。
if ($sentmail) {
header('Location: http://example.com/after_true_statement_redirected');
// exit; ???
} else {
echo "Problem sending information, please resubmit.";
}发布于 2011-10-23 09:56:26
您可以使用header();函数来完成此操作。
if($sentmail){
header("Location: http://mypage.com/redirect.php");
die();
}
else {
echo "Problem sending information, please resubmit.";
}使用die();停止脚本执行。虽然页面会重定向,但脚本仍会执行。
发布于 2011-10-23 09:59:41
最简单的重定向调用是PHP中的http_redirect。执行重定向所需的所有操作。
if ($sentmail)
{
http_redirect('new location');
}
else
{
echo "Problem sending information, please resubmit.";
}https://stackoverflow.com/questions/7863865
复制相似问题