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");
}
}
}
?>
欢迎来到Stack Overflow!请正确格式化您的代码。通过在任何代码行之前缩进4个空格来插入代码块。我这次为您编写了代码格式,但下次请正确格式化。如需进一步的帮助,请参阅[编辑常见问题](http://stackoverflow.com/editing-help#code) – 2012-08-05 19:24:28
酷,尽我所能。但是,无论如何,我可以得到这个帮助吗? – user1577774 2012-08-05 19:25:49
另外,欢迎使用堆栈溢出!请不要使用'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