Php 没有给出正确的信息
我正在试图弄清楚为什么当用户被锁定并且还没有10分钟时,他们会收到一条消息: 帐户已解锁。您现在可以尝试再次登录 我不知道为什么Php 没有给出正确的信息,php,Php,我正在试图弄清楚为什么当用户被锁定并且还没有10分钟时,他们会收到一条消息: 帐户已解锁。您现在可以尝试再次登录 我不知道为什么 // User is registered and verified $query = "SELECT * FROM users_logins_attempts WHERE users_id = '".$users_id."'"; $result = mysqli_query($dbc,$query); $row = mysqli_fetch_array($resul
// User is registered and verified
$query = "SELECT * FROM users_logins_attempts WHERE users_id = '".$users_id."'";
$result = mysqli_query($dbc,$query);
$row = mysqli_fetch_array($result);
$lock_date = $row['lock_date'];
$current_time = time();
// Find out if user is locked out of their account
if (($lock_date != "0000-00-00 00:00:00") && strtotime($lock_date) < $current_time) {
$lock_date = strtotime($lock_date);
$diff = $current_time - $lock_date;
$diff = floor($diff/60);
// Take minutes and perform tasks
if ($diff <= 10) {
// Calculate time remaining
$time_remaining = 10 - $diff;
// Account locked error
$errors = true;
$message = "Account is locked. You must wait " .$time_remaining." minutes before you can log in again!";
$output = array('errorsExist' => $errors, 'message' => $message);
} else {
// Clear the lock
$query = "UPDATE users_logins_attempts SET lockDate = NULL, ip_address = NULL, failed_logins = 0 WHERE users_id = '".$users_id."'";
$result = mysqli_query($dbc,$query);
// Account locked error
$errors = true;
$message = "Account is unlocked. You may now try to log in again!";
$output = array('errorsExist' => $errors, 'message' => $message);
}
}
//用户已注册并验证
$query=“选择*来自用户\登录\尝试,其中用户\ id=”“$users \ id。””;
$result=mysqli_查询($dbc,$query);
$row=mysqli\u fetch\u数组($result);
$lock_date=$row['lock_date'];
$current_time=time();
//了解用户是否被锁定在其帐户之外
如果($lock_date!=“0000-00-00 00:00:00”)&&strotime($lock_date)<$current_time){
$lock\u date=strottime($lock\u date);
$diff=$current\u time-$lock\u date;
$diff=楼层($diff/60);
//花上几分钟完成任务
如果($diff$错误,'message'=>$message);
}否则{
//把锁打开
$query=“更新用户\u登录\u尝试设置锁定日期=NULL,ip\u地址=NULL,失败的\u登录=0,其中用户\u id=”“$users\u id。””;
$result=mysqli_查询($dbc,$query);
//帐户锁定错误
$errors=true;
$message=“帐户已解锁。您现在可以尝试再次登录!”;
$output=array('errorsExist'=>$errors,'message'=>$message);
}
}
您可能使用的是毫秒而不是秒。尝试除以60000而不是60。在这种情况下,程序员通常会调试代码。走完每一行,做测试输出,直到你找到罪魁祸首。请缩小范围。我们不是来做你的家庭作业的。找到错误,然后发布较小的代码@NullUserException:我的投票过于本地化,不太可能帮助其他人。完全正确。strotime()
返回一个Unix时间戳(秒)。我需要几分钟,所以我注意到它必须是6000。谢谢你是唯一乐于助人的人。