问题是,由于某些奇怪的原因,我调用方法的代码没有调用方法,这个方法是锁定的()。这是我的班级:
class login
{
public $username;
public $password;
public $fails;
public $ip;
public $sqlObject;
public function sqlVerify() {
$user=$this->username;
$pass=$this->password;
$sqlObject=$this->sqlObject;
$fails=$this->fails;
if($fails >= 4) { $this->locked(); }
$query=mysqli_query($sqlObject,
"SELECT 1 FROM tbl_users
WHERE username='$user' AND password='$pass'");
if(mysqli_num_rows($query) > 0){
return "1";
}else{
return "0";
}
}
private function locked() {
return "For security, this account has been locked. Contact support.";
}
}
此时失败的值= 9,仍然没有通话..?
答案 0 :(得分:3)
请尝试使用以下代码:
public function sqlVerify() {
$user=$this->username;
$pass=$this->password;
$sqlObject=$this->sqlObject;
$fails=$this->fails;
if($fails >= 4) { return $this->locked(); } // You need to put return statement here also for returning from this function.
$query=mysqli_query($sqlObject,
"SELECT 1 FROM tbl_users
WHERE username='$user' AND password='$pass'");
if(mysqli_num_rows($query) > 0){
return "1";
}else{
return "0";
}
}
private function locked() {
return "For security, this account has been locked. Contact support.";
}