【发布时间】:2016-05-05 19:01:04
【问题描述】:
即使值应该相等,它也不会计算,它直接进入 else 事件。表列名与数据库匹配,所以...
我需要在 ($recruitcheck==$recruitpass) 中使用某种类型的引号吗?
$recruiter = $_POST["recruiter"];
$recruitpass = $_POST["recruitpass"];
$recruitcheck = mysqli_query($maindb, "select aurapass from auras where auraname='$recruiter'");
if($recruitcheck == $recruitpass) {
$badgecheck = mysqli_query($maindb, "select recruitbadge from auras where auraname='$recruiter'");
if($badgecheck == "0") {
echo "<script>alert('Recruiter information correct, but there is no recruit badge.')</script>";
exit();
} else {
echo "<script>alert('Recruiter badge accepted.')</script>";
$emailcheck = mysqli_query($maindb, "select * from auras where email='$email'");
$namecheck = mysqli_query($maindb, "select * from auras where auraname='$auraname'");
if(mysqli_num_rows($emailcheck) > 0 || mysqli_num_rows($namecheck) > 0){
echo "<script>alert('New auraname/email is already taken.')</script>";
exit();
} else {
exit();
}
}
} else {
echo "<script>alert('Aura information of recruiter is incorrect. Please, use preexisting aura information to confirm recruiter identity.')</script>";
exit();
}
【问题讨论】:
-
$recruitpass是一个字符串,$recruitcheck是不是一个字符串。 -
通过使用
var_dump打印出变量来检查变量。mysqli_query返回一个资源,因此它永远不会等于字符串值。 php.net/manual/en/mysqli-result.fetch-row.php -
获取行以从数据库中获取数据。
-
看在上帝的份上,不要将密码存储为纯文本。 php.net/manual/en/function.password-hash.php 和 php.net/manual/en/function.password-verify.php
标签: php function mysqli syntax local-variables