ririe44 Posted August 29, 2009 Share Posted August 29, 2009 Okay, this will be basic... but at the same time I'm not really sure what to search for. I need to generate user level access controls to my site. My site will have 5 different levels: level1, level2, level3, sales, and admin. I will have 5 pages as well... level1, level2, level3, sales, and admin. The admin user will be able to see all 5 pages. The sales user will only be able to see level1 to sales. The level3 user will be able to see level1-level3... and so on. My user database will have these levels specified. Can you either help guide me towards my solution, or to another post/tutorial that could help me think through this? Thank you! Quote Link to comment Share on other sites More sharing options...
trq Posted August 29, 2009 Share Posted August 29, 2009 Google the concept of using bitwise user permissions or something similar. Quote Link to comment Share on other sites More sharing options...
ririe44 Posted August 29, 2009 Author Share Posted August 29, 2009 Okay, I'm taking a stab at this here... play along with me (I'm very new to this)... checklogin.php $username=$_POST['username']; $password=$_POST['password']; $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'"; $result=mysql_query($sql); $access=$result['access']; if($access=='admin'){ $perms==6; }elseif($access=='sales'){ $perms==5; }elseif($access=='pkg3'){ $perms==4; }elseif($access=='pkg2'){ $perms==5; }elseif($access=='pkg1'){ $perms==2; } $count=mysql_num_rows($result); if($count==1){ session_start(); $_SESSION["logged"] = 1 + $perms; header("location:../members.php"); } else { $_SESSION["logged"] < 1 | > 7; echo "<div align=center>The username and password you have provided are incorrect.<br>"; echo 'Return to <a href="./login.html">Login</a></div>'; } So, as you can see I'm giving my user access a number level... 6 = admin, 5 = sales, etc. I want my session to equal 1 + the access level ($perms)... which I'll use for my session status to help control access to certain pages... what i'm not sure about is the else part... <1, or >7.... help? Quote Link to comment Share on other sites More sharing options...
ririe44 Posted August 29, 2009 Author Share Posted August 29, 2009 So, I'm obviously digging into this a bit... what about making the session name the access level... then I could allow access to pages based on the session name? Quote Link to comment Share on other sites More sharing options...
trq Posted August 29, 2009 Share Posted August 29, 2009 Id write you another example but there seems plenty around, take a look at this tutorial I just googled. Quote Link to comment Share on other sites More sharing options...
trq Posted August 29, 2009 Share Posted August 29, 2009 Oh, and yeah. Once you have the bitwise idea sorted... The users $_SESSION array is a great place to store there access level. Quote Link to comment Share on other sites More sharing options...
ririe44 Posted August 29, 2009 Author Share Posted August 29, 2009 I am so confused... does anybody have an actual script that I can reference? So I can see how it's done? 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.