Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
成功注册后,重定向到php中的其他页面_Php_Redirect - Fatal编程技术网

成功注册后,重定向到php中的其他页面

成功注册后,重定向到php中的其他页面,php,redirect,Php,Redirect,我正在尝试创建一个网站,其目的是当注册成功时重定向到finish.php,否则将位于同一页面上,即register.php 代码如下: try { $mail->send(); $msg = "An email has been sent for verfication."; echo "<script type='text/javascript'>alert('$msg');</script>";

我正在尝试创建一个网站,其目的是当注册成功时重定向到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";

        }
试试看{
$mail->send();
$msg=“已发送电子邮件进行验证。”;
回显“警报('$msg');”;
重定向(“finish.php”);
$msgType=“成功”;
}
在上述代码中,插入数据库的功能已完成。警告消息显示在页面上,但页面未重定向到finish.php 我的表单提交如下所示:

<form action="free_register.php"  class="form-horizontal well" method="post" name="f" onsubmit="return validateForm();">

您应该使用标题(“位置: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";
}
/*PHP*/
试一试{
$mail->send();
$msg=“已发送电子邮件进行验证。”;
标题(“位置:finish.php”);
$msgType=“成功”;
}
/*JS*/
试一试{
$mail->send();
$msg=“已发送电子邮件进行验证。”;
回显“警报('$msg');”;
echo“window.location='finish.php';”;
$msgType=“成功”;
}

这两个例子都有效。如果没有,请检查try块或澄清“什么不起作用”

只需在js代码中添加
window.location='finish.php'
,在
警报后添加
,谢谢,但这不会重定向…它保持不变page@anonymous这个网站应该不用js就可以运行。@user877329我知道,但他是在重复javascript代码,因此,
header
php函数将不起作用,并将引发一个header-ready-sent错误。谢谢,但这不会重定向…它将保持在同一页面上更新我的第一个答案。