Choosing a page to go to based upon a mysql query.

Here is the code I need help. I want this to go to a different page if the client was created before 10/25/2010.

<?php // start output buffering because including the // dbconfig file causes headers to be sent messing // up the cookie set functions. ob_start(); include_once 'dbconfig.php'; include_once 'functions.php'; // Use this variable to communicate to user if they enter the wrong username, password, etc. $message = 'If you do not have an account please sign-up here.'; //Checks if there is a login cookie if (check_user_cookie()) { ?><?php

}

//if the login form is submitted
if (isset($_POST[‘submit’])) {
// makes sure they filled it in
if(!$_POST[‘username’] | !$_POST[‘pass’]) {
$message = ‘You did not fill in a required field. Please Fill in all fields.’;
}
else {

    // checks it against the database
    $check = 'SELECT * FROM user WHERE username = ?';
    $sth   = prep_exec($check, array($_POST['username']));

    # If the user does not exist fetch() returns false 
    if ($info = $sth->fetch()) {
        $banlevel = $info['banlevel'];
        $deny     = 2;
        $_POST['pass'] = stripslashes($_POST['pass']);
        $info['password'] = stripslashes($info['password']);
        $_POST['pass'] = md5($_POST['pass']);

        //gives error if the password is wrong
        if ($_POST['pass'] != $info['password']) {
            $message = 'Incorrect password, please try again.';
        }
        elseif ($banlevel == $deny) {
                $message = "Sorry You Are not Authorized by the admin Please comtact Admin at [email protected]";
        }
        else {

            // if login is ok then we add a cookie 
            $_POST['username'] = stripslashes($_POST['username']); 
            $hour = time() + 3600; 
            setcookie(ID_my_site, $_POST['username'], $hour); 
            setcookie(Key_my_site, $_POST['pass'], $hour); 

            // Must manually put in username since setcookie hasn't completed yet
            log_msg($_POST['username'] . " Logging in");
            if ($_POST['javascript'] == 1) {
                log_msg($_POST['username'] . " Javascript enabled");
            }
            else {
                log_msg($_POST['username'] . " Javascript disabled");
            }


            //then redirect them to the members area 
            ?><meta http-equiv="refresh" content="0;URL=memberarea.php" /><?php
        } 
    }
    else {
        $message = 'That username does not exist in our database. <a href=register.php>Click Here to Register</a>';
        $_POST['username'] = '';
    }
}

}

?>

Login

Username:
Password:
 
 
<?= $message ?>

Forgot your password?
<?php

?>

Probably in your table ‘users’ you have a date field that stores date when user has registered. You need to compare that date with today’s date and redirect to another page based on result of this comparison.

I do understand that I have to do a redirect but in this code where do I put it. I am very limited in my PHP skills and need an answer fast. In the user table the field is called datecreated. But the username is based off the login screen it checks it to see if it is valid.

Sponsor our Newsletter | Privacy Policy | Terms of Service