Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.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
url中的PHP头传递参数_Php_Header_Http Headers - Fatal编程技术网

url中的PHP头传递参数

url中的PHP头传递参数,php,header,http-headers,Php,Header,Http Headers,我有一个index.php用于注册,一个login.php作为注册处理程序。当注册失败时,它向客户端发送错误消息。我用这个代码发送信息 header('Location: http://localhost/musicshare/index.php?reg=false'); 并在index.php中接收 if(isset($_POST['reg'])){ echo 'set';//for checking whether reg is set if($_POST[

我有一个index.php用于注册,一个login.php作为注册处理程序。当注册失败时,它向客户端发送错误消息。我用这个代码发送信息

header('Location: http://localhost/musicshare/index.php?reg=false');
并在index.php中接收

if(isset($_POST['reg'])){
        echo 'set';//for checking whether reg is set
        if($_POST['reg']=='false'){
            echo '<script type="text/javascript">';
            echo 'alert("Reg faile")';
            echo '</script>';
        }
    }
if(isset($\u POST['reg'])){
echo“set”;//用于检查是否设置了reg
如果($_POST['reg']=='false'){
回声';
回显“警报”(“Reg故障”);
回声';
}
}

然而,它似乎根本不起作用;请帮助,谢谢。

使用
$\u GET
而不是
$\u POST

if (isset($_GET['reg']) && $_GET['reg'] == 'false'){
   // do something
}
当您使用header()时,它会触发一个
GET
请求

所以您应该使用$\u GET['reg']

if(isset($_GET['reg'])){
    echo 'set';//for checking whether reg is set
    if($_GET['reg']=='false'){
        echo '<script type="text/javascript">';
        echo 'alert("Reg faile")';
        echo '</script>';
    }
}
if(isset($\u GET['reg'])){
echo“set”;//用于检查是否设置了reg
如果($\u GET['reg']=='false'){
回声';
回显“警报”(“Reg故障”);
回声';
}
}

如果您的问题得到了回答,请接受合适的答案。