没有给出正确的信息

时间:2011-09-05 19:37:35

标签: 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($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);

    } 

} 

1 个答案:

答案 0 :(得分:1)

您可能使用的是毫秒而不是秒。尝试除以60000而不是60。