我成功地创建了一个表单,通过电子邮件为我的公司请求报价。它起作用——数据收集、验证和电子邮件发送。该页面位于:
http://www.bardonsoliver.com/newbnocm/request_quote.shtml
然而,我想重定向到一个感谢页面,网址是:
http://www.bardonsoliver.com/newbnocm/thank_you.shtml
起初,当我运行表单时,它重定向得很好。现在我只在脚本页面的左上角显示一个零。
由于错误消息,我不得不从"标题"改为"位置"。
这是脚本的结尾,直接在创建和发送电子邮件的代码之后:
if( $mailsend = TRUE) {
unset($_GET['do']);
printf("<script type='text/JavaScript'>location='" + $typage +"'</script>");
exit;
} else {
unset($_GET['do']);
printf("<script type='text/JavaScript'>location='" + $retpage +"'</script>");
printf("<script type='text/JavaScript'>window.alert('We are unable to send your e-mail at this time. Please contact Ben through the contact page or try again later. Thank you.')</script>");
exit;
}
$typage先前设置为:
$typage='../thank_you.shtml';
$retpage是:
$retpage='../request_quote.shtml';
路径是正确的——脚本比所有页面所在的主目录"低一级"。
我是一个相对初级的PHP,我相信有比我更专业的人会看到这一点,并立即发现问题。谢谢
你可能应该这样做:
echo "<script type='text/JavaScript'>window.location.href='" + $typage +"'</script>";
使用Javascript作为重定向会起作用。。我很好奇你收到了什么错误信息。我还很好奇你是如何在一个扩展名为.shtml的文件中运行php代码的——你有没有将apache配置为将.shtml作为php运行?
我认为最简单的方法是,在确认您的邮件已发送后,使用以下代码:
header("Location: http://www.example.com/");