我的PHP:
我正在尝试在用户输入正确信息后重定向脚本。我知道它有:
header("Location: site");
但是在提交后它没有重定向。它确实登录,因为当我刷新时,它会重定向到/site
和想法?
$submit = $_POST['submit'];
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
if ($submit) {
if ($username&&$password) {
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$numrows = mysql_num_rows($query);
if ($numrows!=0) {
while ($row = mysql_fetch_assoc($query)) {
$dbusername = $row['username'];
$dbpassword = $row['password'];
$rank = $row['rank'];
}
if ($username==$dbusername&&md5($password)==$dbpassword) {
header("Location: site");
$_SESSION['username']=$username;
} else
echo "<div class='alert alert-error'><strong>Error:</strong> Incorrect password!</div>";
}else
echo "<div class='alert alert-error'><strong>Error:</strong> The user you entered doesn't exist!</div>";
}else
echo "<div class='alert alert-error'><strong>Error:</strong> Please enter a username or password!</div>";
}
这是我的完整代码: