我正在尝试创建一个网站,其目的是在注册成功时重定向到finish.php否则在同一页面上,即register.php 代码如下:
try {
$mail->send();
$msg = "An email has been sent for verfication.";
echo "<script type='text/javascript'>alert('$msg');</script>";
redirect("finish.php");
$msgType = "success";
}
在上面的代码中完成了插入db的功能。警报消息显示在页面上,但页面未重定向到finish.php 我的表单提交如下:
<form action="free_register.php" class="form-horizontal well" method="post" name="f" onsubmit="return validateForm();">
答案 0 :(得分:1)
您应该使用标题(“位置:dashboard.php”)
<强>更新强>
您有两种选择。用js或php重定向。
/* PHP */
try {
$mail->send();
$msg = "An email has been sent for verfication.";
header("Location: finish.php");
$msgType = "success";
}
/* JS */
try {
$mail->send();
$msg = "An email has been sent for verfication.";
echo "<script type='text/javascript'>alert('$msg');</script>";
echo "<script type='text/javascript'>window.location = 'finish.php';</script>";
$msgType = "success";
}
这两个例子都有效。如果没有,请检查您的尝试块或澄清“什么不起作用”。