Jump to content

User Level Help


ririe44

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/172360-user-level-help/
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/172360-user-level-help/#findComment-908809
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.