可能是一些简单的东西我错过了,但我要做的是完成注册表格,并在它发送确认电子邮件后,将其重定向到另一个页面。到目前为止
if($sentmail){
<redirection code>
}
else {
echo "Problem sending information, please resubmit.";
}
您希望header()
,可能还有exit
停止处理。
if ($sentmail) {
header('Location: http://example.com/after_true_statement_redirected');
// exit; ???
} else {
echo "Problem sending information, please resubmit.";
}
可以使用header();
函数。
if($sentmail){
header("Location: http://mypage.com/redirect.php");
die();
}
else {
echo "Problem sending information, please resubmit.";
}
使用die();
停止脚本执行。虽然页面重定向,脚本仍然执行。
PHP中最简单的重定向调用是http_redirect
。完成重定向所需的所有操作。
if ($sentmail)
{
http_redirect('new location');
}
else
{
echo "Problem sending information, please resubmit.";
}