Jump to content

[SOLVED] Login Help


unidox

Recommended Posts

Here is my code:

 

    //Variables
    $password = md5($_POST['password']); // Encrypts the password.
    $username = escape_data($_POST['username']);

    //MySQL Query
    $q = mysql_query("SELECT * FROM `pcp_users` WHERE password = '$password' && username = '$username'");
    $r = mysql_fetch_array($q);

    if (($username == "username") || ($password == "password")) { // Makes sure the user isint entering the default.
        // Redirects to the main login page.
        header("Location: index.php?p=login");
    } elseif (($r['password'] == $password) && ($r['username'] == $username)) { // Makes sure the username and password match up.
        if ($r['conf'] != 1) {
            header("Location: index.php?p=login&e=6");
        } else {
            $level = $r['level'];
            // Session Registering.
            session_register("login"); // Registers the main login session.
        	$_SESSION['login'] = 1; // The user us logged in.
            $_SESSION['name'] = $username; // Sets the users username.
            $_SESSION['level'] = $level; // Sets the users level. So admins can set page level access.
            header("location: index.php?p=user_home"); // Redirects to the user's home page.
        }
    } else {
        //Incorrect Password
    	header("location: index.php?p=login&e=1");
    }

 

and in my index.php?p=user_home I do

Your access level is <? echo $_SESSION['level']; ?>

 

But it says my access level is "Array"

 

Whats wrong?

Link to comment
https://forums.phpfreaks.com/topic/89016-solved-login-help/
Share on other sites

I did this...

 

// header("Location: index.php?p=user_home"); // Redirects to the user's home page.
            $level = $r['level'];
        	$_SESSION['login'] = 1; // The user us logged in.
            $_SESSION['name'] = $username; // Sets the users username.
            $_SESSION['level'] = $level; // Sets the users level. So admins can set page level access.
            echo $_SESSION['level'];

and it says 1, so there is nothing wrong with that. But when it redirects it turns it into "array" :( Whats wrong?

Link to comment
https://forums.phpfreaks.com/topic/89016-solved-login-help/#findComment-455873
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.