用PHP登录您的帐户已过期显示消息

时间:2015-05-08 12:45:39

标签: php login

我有像这样的表格字段

Username| Email | Password | Activation | Expirydate| Createddate
----------------------------------------------------------------------
niranjan|niranjan@gmail.com|12345|NULL| 2015-05-23| 2015-05-08

当用户登录登录页面时,我的查询在下面写着:

if (empty($error)) {
    $date = date('Y-m-d');
    $query_check_credentials = "SELECT * FROM members WHERE (Email='$Email' AND password='$Password') AND (Activation IS NULL) AND (Expirydate <= '$date')";
    $result_check_credentials = mysqli_query($dbc, $query_check_credentials);

    if (@mysqli_num_rows($result_check_credentials) == 1) {
        header('Location: course.php');
        $_SESSION = mysqli_fetch_array($result_check_credentials, MYSQLI_ASSOC);
    } else {
        $msg_error = 'Either Your Account is inactive or Email address /Password is Incorrect';
    }

} else {
    echo '<div class="errormsgbox"> <ol>';
    foreach ($error as $key => $values) {
        echo '  <li>' . $values . '</li>';
    }
    echo '</ol></div>';
}

这里我想当用户登录登录页面时首先检查错误,然后检查表成员,Expirydate&lt; =当前日期我想显示错误消息。请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

你可能想要这样:

"SELECT * FROM members WHERE (Email='".$Email."' AND password='".$Password."') AND (Activation IS NULL) AND (Expirydate <= '".$date."')";

假设$ Email,$ Password和$ date在代码中先前定义。此外,您应该确保在SQL注入方面正确处理这些变量。