Block user after nth login attempt - PHP

安稳与你 提交于 2019-12-01 09:12:06

Your $data is only containing number of rows in mysql

 $data = mysqli_num_rows($result);

Consider using mysqli_fetch_row

you are not fetching Logs table data depend on the user. you should add this line right before $data['loginAttempt'] and change this $data['loginAttempt'] to $LoginAttempt

$LoginAttempt = mysqli_query($con, "SELECT loginAttempt FROM Logs WHERE contractNumber='$cnumber'");

So your condition to check attempt request will be like

if($LoginAttempt >= 3){
// Your code goes here
}

You need to get the $loginAttempt before checking if it is lower than 3. Try something like this:

$loginAttempt = mysqli_query($con, "SELECT * FROM Users WHERE contractNumber='$cnumber')->fetch_object()->loginAttempt;

if($loginAttempt >= 3) {
  ...
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!