Jump to content

[SOLVED] Log in Script


enemeth

Recommended Posts

Hello All,

 

I got a problem, Ofcourse ! 

 

i have a checkuser.php for my site , to get users to log in with there credentials that have been emailed to them , all goes well up until log in ! 

 

here is the code and error is : Parse error: parse error, unexpected T_VARIABLE in /home/www/thetruthdiscovered.com/checkuser.php on line 16

 

<?

/* Check User Script */

session_start();  // Start Session

include 'db.php';

// Conver to simple variables

$username = $_POST['username'];

$password = $_POST['password'];

if((!$username) || (!$password)){

    echo "Please enter ALL of the information! <br />";

    include 'login.php;

    exit();

}

// Convert password to md5 hash

$password = md5($password);

// check if the user info validates the db

//ERROR IS HERE //  $sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1'");

$login_check = mysql_num_rows($sql);

if($login_check > 0){

    while($row = mysql_fetch_array($sql)){

    foreach( $row AS $key => $val ){

        $$key = stripslashes( $val );

    }

        // Register some session variables!

        session_register('first_name');

        $_SESSION['first_name'] = $first_name;

        session_register('last_name');

        $_SESSION['last_name'] = $last_name;

        session_register('email_address');

        $_SESSION['email_address'] = $email_address;

        session_register('special_user');

        $_SESSION['user_level'] = $user_level;

        mysql_query("UPDATE users SET last_login=now() WHERE userid='$userid'");

        header("Location: login_success.php");

    }

} else {

    echo "You could not be logged in! Either the username and password do not match or you have not validated your membership!<br />

    Please try again!<br />";

    include 'login.php';

}

?>

 

Can someone go over that and tell me why i keep getting that error ?  BTW the users are already activated to 1

 

Thank you for all your help ;)

 

Elaine

Link to comment
https://forums.phpfreaks.com/topic/45547-solved-log-in-script/
Share on other sites

<?

/* Check User Script */

session_start();  // Start Session

include 'db.php';

// Conver to simple variables

$username = $_POST['username'];

$password = $_POST['password'];

if((!$username) || (!$password)){

    echo "Please enter ALL of the information!

";

    include 'login.php; // i think Prb is here 'login.php'(forget to close quates)

    exit();

}

 

Link to comment
https://forums.phpfreaks.com/topic/45547-solved-log-in-script/#findComment-221103
Share on other sites

if(!isset($username) || !isset($password)){
    echo "Please enter ALL of the information!
";
    include 'login.php';
    exit();
}

 

 

edit: Don't forget to check the code I just posted again. I noticed you were missing a ' in your include line, so I updated that also.

edit2: I just realized that the ' problem was already addressed :D

Link to comment
https://forums.phpfreaks.com/topic/45547-solved-log-in-script/#findComment-221184
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.