mySQLi查询没有提供正确的信息

时间:2014-01-25 13:51:19

标签: php mysql mysqli

我制作了这个剧本:

$username = $_POST["username"];
$password = sha1($_POST["password"]);
$checkuser_query = mysqli_query($con,"SELECT * FROM users WHERE username='$username' AND password='$password'");
$checkuser = mysqli_num_rows($checkuser_query);
$checkactive_query = mysqli_query($con,"SELECT * FROM users WHERE username='$username' AND verified='0'");
$checkactive = mysqli_num_rows($checkactive_query);
$checkbanned_query = mysqli_query($con,"SELECT * FROM users WHERE username='$username' AND closed='1'");
$checkbanned = mysqli_num_rows($checkactive_query);
if(empty($_POST["username"]) || empty($_POST["password"])) {
    header("Location: http://empirebattles.co.uk/Login?alert=nofilled");
}
elseif($checkuser<= 0) {
    header("location: http://empirebattles.co.uk/Login?alert=loginfailed");
}
elseif($checkactive==1) {
    header("location: http://empirebattles.co.uk/Login?alert=unverified");
}
elseif($checkbanned==1) {
    header("location: http://empirebattles.co.uk/Login?alert=banned");
}       
else {
    header("Location: http://empirebattles.co.uk/Home");
    setcookie("EmpireBattles",$username,time() + (10 * 365 * 24 * 60 * 60),"/");
    mysqli_query($con,"UPDATE users SET online = '1' WHERE username = '$username'");
}

而且,它有效。如果你被禁止,直到重定向你为止。即使你被禁止,它也会跳过它。

我看了一眼,搜索了它,甚至问我的老师,没有人能看出什么是错的。

请看看, 汤姆。

1 个答案:

答案 0 :(得分:0)

尝试更改此行:

  $checkbanned = mysqli_num_rows($checkactive_query);

  $checkbanned = mysqli_num_rows($checkbanned_query );