没有继续脚本php的重定向页面

没有继续脚本php的重定向页面

问题描述:

I have to check information from a form and if it is false I want my user redirected without the script continuing. It works with header:location but the script continues to execute.

An example:

        foreach ($array as &$value) {
        if (empty($value)){
                header("location:garagecreation.php");

                }
    }
 ..... code code 

If my $value is empty I want the script to stop and redirect.

Thanks for the time spent reading this.

我必须检查表单中的信息,如果是false,我希望我的用户重定向而不继续脚本。 它适用于header:location但脚本继续执行。 p>

示例: p>

  foreach($ array as& $ value  ){
 if(empty($ value)){
 header(“location:garagecreation.php”); 
 
} 
} 
 .....代码
  code>  
 
 

如果我的$值为空,我希望脚本停止并重定向。 p>

感谢您花时间阅读本文。 p> DIV>

You need to use exit with header, like this

header("location: garagecreation.php");
exit;

You have to use :

header("location:garagecreation.php"); die();