URL view by User Level

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spudmclard
Forum Newbie
Posts: 16
Joined: Thu Oct 27, 2005 3:06 am

URL view by User Level

Post by spudmclard »

Is there a way to display URLS depending on user access level.
I have a MySQL database holding Username/Password/Userlevel.
Is it possible when the user has been validated that their access level is checked and then the relevant URLs are displayed.

ie..
User1 access level1 -Url A
User2 access level2 -Url A & Url B
USer3 access level3 -UrlA & UrlB & UrlC

Thanks
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Er...

Code: Select all

<?php

if ($userlevel >= 1)
{
    print "<a href="blah.php">This</a>";
}
if ($userlevel >= 2)
{
    print "<a href="blah2.php">This2</a>";
}

// etc...
Better, actually, to use a switch(), but I'll leave you to look at that yourself...
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Code: Select all

Table Name - apps /*stores application & access rules*/

| id | name | url | access_level |
| 01 | Bond | http://van-dame.com/1 | 1 |
| 02 | Pond | http://van-dame.com/2 | 2 |
| 03 | Cond | http://van-dame.com/3 | 3 |
does that give you :idea: :)

edit: btw the last entry (3) will show in both levels i.e. 1 & 2 ( 1|2 = 3 ;) )
Last edited by n00b Saibot on Thu Oct 27, 2005 8:35 am, edited 1 time in total.
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Doesn't he need all three urls for people with level 3 access?
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

see my edit. i think i will explain more...
i store permissions in bits-form (saves space ;) )
i.e.
> lowest level - 1
> middle level - 2
> top level - 4

therefore

> links for all - 4|2|1 = 7
> links for med & top - 4|2 = 6
> links for top & lowest - 4|1 = 5

in this way i can easily isolate any two levels without having to implement extra checks 8)
spudmclard
Forum Newbie
Posts: 16
Joined: Thu Oct 27, 2005 3:06 am

Post by spudmclard »

Thanks everyone..Gives me plenty to work on :)
Post Reply