How to check email password and expiry date during authentication?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tutusaint
    New Member
    • Sep 2010
    • 18

    #1

    How to check email password and expiry date during authentication?

    I have a user login authentication scrip which validates users emailid and password.
    I want it to also check and validate users expiry date in the database.

    I have user details like name, emailid, password, regdate, expiry (expiry date).

    I want the autentication script to validate with emailid, password and expiry.

    Code:
    <?php
    include "dbCon.php";
    
    $EmailAd = $_POST['EmailAd'];
    $Password = $_POST['Password'];
    
    $query = mysql_query("SELECT * from user where EmailAd = '$EmailAd'
    						AND Password = '$Password'");
    						
    $row = mysql_fetch_array($query);
    
    if ($row) {
    	session_start();
    	$_SESSION['EmailAd'] = $_POST['EmailAd'];
    	header ('Location: home.php');
    	exit();
    	}
    else {
    	header ('Location: loginFailed.php');
    	exit();
    	}
    ?>
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Add a check for the expiry date into your where clause of your query.

    You should be using mysql_real_esca pe_string() on all user submitted data otherwise you are leaving yourself open to mysql injection attacks.

    Comment

    Working...