【问题标题】:header of php not redirecting to mention pagephp的标头没有重定向到提及页面
【发布时间】:2014-03-02 01:06:38
【问题描述】:

我正在使用php的header函数重定向到索引页面,但是重定向后,出现了一个错误,你没有连接到网络。

两个文件都在同一个目录中。

代码是

function chklogin()
{
  require('script/session.php');
  if(isset($usernmae))
     {   
      echo "welcome";
     }
     else
     { 
      header('location: index.php');
     }
 }
header('location: index.php');

【问题讨论】:

  • 我的系统上没有您的代码副本。也许发布它会很棒。
  • 嗯?你能解释一下吗?仅在 index.php 上发生?
  • 这里没有足够的信息。 $username 甚至在范围内吗?它甚至拼写不正确。

标签: php networking redirect header


【解决方案1】:

请将您的代码更改为此,然后尝试 :)

function chklogin()
{
  require('script/session.php');
  if(isset($username))
     {   
      echo "welcome ".$username;
     }
     else
     { 
      header('Location: /index.php');
     }
}
chklogin();

【讨论】:

    猜你喜欢
    • 2011-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多