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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.