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