简体   繁体   English

mySQLi查询未提供正确的信息

[英]mySQLi Query not giving correct information

I made this script: 我做了这个脚本:

$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'");
}

And, it works. 并且,它起作用。 Up until the point where it redirects you if you are banned. 直到禁止您重定向它为止。 It just skips it , even if you are banned. 即使您被禁止,它也会跳过它。

I've had a look, googled it and even asked my teacher, nobody can see what's wrong. 我看了一遍,用谷歌搜索,甚至问我的老师,没有人知道有什么问题。

Please have a look, Tom. 汤姆,请看看。

try changing this line: 尝试更改此行:

  $checkbanned = mysqli_num_rows($checkactive_query);

to

  $checkbanned = mysqli_num_rows($checkbanned_query );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM