I need a script for logging login attempts: if a user attempts to login 3 times with the wrong password, then script will alert user to log in another way.
I tried this way but it's not working. How should I make this work? An explanation of the implementation of the code would also be appreciated.
public function log($usrname, $password, $type) {
try {
$stmt = $this->db->prepare("SELECT * FROM $table WHERE username=:username and password =:password and type=:type");
$stmt->execute(array(':username' => $usrname, ':password' => $password, ':type' => $type));
$userRow = $stmt->fetch(PDO::FETCH_ASSOC);
if ($stmt->rowCount()== 1) {
echo "loged in";
} else if($stmt->rowCount == 0){
$ec = 0;
$error = ++$ec;
if(count($error)== 3){
echo "you provide wrong username and password 3 times";
}
}
}
} catch (PDOException $e) {
$e->getMessage();
}
}