unidox Posted February 2, 2008 Share Posted February 2, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/89016-solved-login-help/ Share on other sites More sharing options...
ryeman98 Posted February 2, 2008 Share Posted February 2, 2008 Everything else works though, right? Quote Link to comment https://forums.phpfreaks.com/topic/89016-solved-login-help/#findComment-455858 Share on other sites More sharing options...
awpti Posted February 2, 2008 Share Posted February 2, 2008 change session_register(...) to just session_start(); Quote Link to comment https://forums.phpfreaks.com/topic/89016-solved-login-help/#findComment-455859 Share on other sites More sharing options...
unidox Posted February 2, 2008 Author Share Posted February 2, 2008 Yea, everything else works, and i already have session_start(); on my index.php. I am using an include and get statements. Quote Link to comment https://forums.phpfreaks.com/topic/89016-solved-login-help/#findComment-455862 Share on other sites More sharing options...
unidox Posted February 2, 2008 Author Share Posted February 2, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/89016-solved-login-help/#findComment-455873 Share on other sites More sharing options...
widox Posted February 2, 2008 Share Posted February 2, 2008 Have you tried doing print_r($_SESSION); to see what's in there exactly? Also do a print_r($r) where you fill $_SESSION to make sure you've got the data you think you do. HTH Quote Link to comment https://forums.phpfreaks.com/topic/89016-solved-login-help/#findComment-455877 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.