devangel Posted March 17, 2010 Share Posted March 17, 2010 hey guys, im making a check user level script. if $usr['authlevel']>4 echo "adminpanel" i have set my sessions. $_SESSION['SESS_USERID'] = $user['userid']; $_SESSION['SESS_USERNAME'] = $user['username']; how do i use the sess_userid to retrieve the users details for the users id only. ive tried :: mysql_query("SELECT * FROM users WHERE userid = '$userid'") or die(mysql_error()); $usr = mysql_fetch_array( $data ); please someone with guidance, ive been searching for hours. i need to make a if statement to check user level, but i havent managed to retrieve db info via session. Quote Link to comment Share on other sites More sharing options...
schilly Posted March 17, 2010 Share Posted March 17, 2010 well you could store the user level in your session when you login then you wouldn't need to query the db. then you can do something like: if ($_SESSION['authlevel']>4) echo "adminpanel"; Quote Link to comment Share on other sites More sharing options...
devangel Posted March 17, 2010 Author Share Posted March 17, 2010 how would i be able to save the authlevel in a session ive tried $user = mysql_fetch_assoc($result); $_SESSION['SESS_USERID'] = $user['userid']; $_SESSION['SESS_USERNAME'] = $user['username']; $_SESSION['SESS_AUTHLEVEL'] = $user['authlevel']; how would you define it into a session? Quote Link to comment Share on other sites More sharing options...
schilly Posted March 17, 2010 Share Posted March 17, 2010 that looks fine to me. make sure your query is actually returning the authlevel column. Quote Link to comment Share on other sites More sharing options...
devangel Posted March 17, 2010 Author Share Posted March 17, 2010 my query doesnt look wrong $qry="SELECT * FROM users WHERE username='$username' AND password='".md5($_POST['password'])."' and authlevel>0"; $result=mysql_query($qry); it checks to see if your banned userlevel (0) but yeah i cant figure out why its saying its not defined i used: <?php if ($_SESSION['authlevel']>4) echo "adminpanel"; ?> and i got Notice: Undefined index: authlevel in on that line. Quote Link to comment 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.