2012-08-05 118 views
0
if(isset($_SESSION['username']) && isset($_SESSION['password'])){ 
header("Location: ../welcome/index.php"); 

我的登录脚本似乎已经停止工作,最近7月19日PHP的新更新。header(“location:...”);没有重定向到新的PHP更新

任何人都可以解决这个问题吗?

这是整个脚本。


<? 
    include_once ('includes.inc.php'); 


    if (!isset($_POST['login']) || (strlen($_POST['username']) < 3) || (strlen($_POST['password']) < 3)) { //User forgot a field 
     header("Location: ../index.php?message=4"); 
    } 
    else { 
     $username = htmlspecialchars(mysql_real_escape_string(trim($_POST['username'])), ENT_QUOTES); 
     $password = sha1(trim($_POST['password'])); 
     $sqlPass = mysql_query("SELECT isbanned, password, id FROM members WHERE username = '" . $username . "'"); 
     $sqlPass = mysql_fetch_array($sqlPass); 


     if (($sqlPass['password'] == NULL) || ($sqlPass['password'] != $password)) { //User entered wrong information 
      header("Location: ../index.php?message=5"); 
     } 
     else if ($sqlPass['isbanned'] == '1') { 
      header("Location: ../index.php?message=50"); 
     } 
     else { 
      $_SESSION['username'] = $username; 
      $_SESSION['password'] = $password; 
      $_SESSION['uid']  = $sqlPass['id']; 

      //Log IP 
      AddIPToLogs(); 


      if (isset($_SESSION['username']) && isset($_SESSION['password'])) { 
       header("Location: ../welcome/index.php"); 
      } 
     } 
    } 
?> 
+0

欢迎来到Stack Overflow!请正确格式化您的代码。通过在任何代码行之前缩进4个空格来插入代码块。我这次为您编写了代码格式,但下次请正确格式化。如需进一步的帮助,请参阅[编辑常见问题](http://stackoverflow.com/editing-help#code) – 2012-08-05 19:24:28

+0

酷,尽我所能。但是,无论如何,我可以得到这个帮助吗? – user1577774 2012-08-05 19:25:49

+0

另外,欢迎使用堆栈溢出!请不要使用'mysql_ *'函数来编写新的代码。他们不再维护,社区已经开始[弃用程序](http://goo.gl/KJveJ)。请参阅* [红盒子](http://goo.gl/GPmFd)*?相反,您应该了解[准备好的语句](http://goo.gl/vn8zQ)并使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli的)。如果你不能决定哪些,[这篇文章](http://goo.gl/3gqF9)会帮助你。如果你选择PDO,[这里是很好的教程](http://goo.gl/vFWnC)。 – 2012-08-05 19:26:29

回答

2

尝试<?php作为起始标记,而不是<?

或者你用在session_start()?

或者您是否曾经在任何地方发过标头?

是否有任何错误,PHP显示?

+0

'<?php'应该可以解决你的问题! – rackemup420 2012-08-05 19:31:28

+0

我是这么认为的,但是没有太多的问题。 – androbin 2012-08-05 19:34:14

+0

抱歉,这里是你的链接。 http://php.net/manual/en/ini.core.php – rackemup420 2012-08-05 19:37:09

0

我首先想到的是,查看提供的代码,是您的if语句有语法错误。声明:

if (!isset($_POST['login']) || (strlen($_POST['username']) < 3) || (strlen($_POST['password']) < 3)) { //User forgot a field 
    header("Location: ../index.php?message=4"); 
} 

应该

if ((!isset($_POST['login']) || (strlen($_POST['username']) < 3) || (strlen($_POST['password']) < 3)) { //User forgot a field 
    header("Location: ../index.php?message=4"); 
} 

此外,您在 '头(' 位置 ')' 之前,有一个 '包括' 语句。您所包含的代码中可能存在问题。

最后,您应该详细说明如何更新系统,从哪个版本的PHP到最新的版本。你是自己做这个更新的,还是你在一个网站托管的服务器上运行?

+0

我正在使用iPage进行托管。 – user1577774 2012-08-05 19:59:25