Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.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,大家好,我正在尝试为我的脚本编写一个小插件这是php代码: <?php if (isset($_SESSION['uid'])) { header('Location: /members'); } else { echo '<table width="40%" border="0" align="center" cellpadding="5" cellspacing="2"> <tr align="center" valign="top">

大家好,我正在尝试为我的脚本编写一个小插件这是php代码:

 <?php
if (isset($_SESSION['uid'])) {
    header('Location: /members');
} else {
    echo '<table width="40%" border="0" align="center" cellpadding="5" cellspacing="2">
  <tr align="center" valign="top"> 
    <td bgcolor="#99CC00" class="thinbord"><font color="#FFFFFF"><strong>قسمت ورود کاربران</strong></font></td>
  </tr>
  <tr align="center" valign="top" bgcolor="#EEF7FF"> 
    <td class="thinbord"><table width="100%" border="0" cellspacing="0" cellpadding="2">
        <form action="/members/" method="post">
          <tr> 
            <td height="25" align="center" valign="bottom" class="boxtext"><strong>email :</strong></td>
          </tr>
          <tr> 
            <td align="center" class="boxtext"><input type="text" name="email" size="20" maxlength="100"></td>
          </tr>
          <tr> 
            <td align="center" class="boxtext"><strong>پسورد:</strong></td>
          </tr>
          <tr> 
            <td align="center" class="boxtext"><input type="password" name="passwd" size="20" maxlength="20"></td>
          </tr>
          <tr> 
            <td align="center" class="boxtext"><input type="hidden" name="form" value="sent" > 
              <input name="submit" type="submit" value="login" ></td>
          </tr>
          <tr> 
            <td align="center" class="boxtext"><a href="/lost.php<? if ($ref) {echo("?ref=$ref"); }?>">lost your pass click here</a>
              <br>please check your spam</b></td>
          </tr>
          <tr> 
            <td align="center" class="boxtext"><a href="/signup.php<? if ($ref) {echo("?ref=$ref"); }?>">sign up</a></td>
          </tr>
        </form>
      </table></td>
  </tr>
</table>';
}?>

它的show偶数会话uid可用脚本将页面重定向到成员,如果它不可用,脚本将显示一个用于登录的表
会话在我转到索引上的此页面之前开始,但它不起作用,并且不会将页面重定向到成员。

我认为此语句需要一些
标题(“位置:/members”)

php.net这样说

标题字符串。 有两个特例头调用。第一个是以字符串“HTTP/(大小写不重要)开头的头,它将用于计算要发送的HTTP状态代码。例如,如果已将Apache配置为使用PHP脚本处理丢失文件的请求(使用ErrorDocument指令),则可能需要确保脚本生成正确的状态代码
第二种特殊情况是“位置:”标题。它不仅将此标头发送回浏览器,而且还将重定向(302)状态代码返回到浏览器,除非已设置201或3xx状态代码

因此,我认为您需要在代码上添加
http://


让我们这样做
标题('位置:http://www.google.com/');。所以,如果你重定向到谷歌,代码是正确的。如果没有,您必须更改某些内容。

脚本中是否包含了
session\u start()
。在处理会话时,您必须在每个脚本中添加
session\u start()
。var\u dump($\u session)并在此处发布转储的答案。这样,如果重定向到google,代码是正确的。如果不是,你必须改变一些东西。
  header('Location: http://www.example.com/');