From: Carlos Sura on 29 Jun 2010 15:46 Hello everyone. I have this question: I'm developing a login system but what I need is to do is access levels I mean, in my database I have this users: Admin Superusers sales purchase etc So, What I do basically need is, when a user from sales log in.. I want him to see just the menu from SALES, He cannot see others menu options, and he can't get access, I was reading that I can do that with Switch, but really I have no idea about it... Any help? Thank you. Carlos Sura. _________________________________________________________________ http://clk.atdmt.com/UKM/go/197222280/direct/01/ Do you have a story that started on Hotmail? Tell us now
From: tedd on 29 Jun 2010 15:58 At 7:46 PM +0000 6/29/10, Carlos Sura wrote: >Hello everyone. > >I have this question: I'm developing a login system but what I need >is to do is access levels > >I mean, in my database I have this users: > >Admin >Superusers >sales >purchase >etc > >So, What I do basically need is, when a user from sales log in.. I >want him to see just the menu from SALES, He cannot see others menu >options, and he can't get access, I was reading that I can do that >with Switch, but really I have no idea about it... Any help? > >Thank you. > >Carlos Sura. Carlos: That's a little like saying, "I want to build a car so I can drive around the country. I was reading that I could do that with a key, but I don't have any idea about it... Any help?" Yes, you can use a switch statement, but that just one control structure in a much, much larger application. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com
From: Carlos Sura on 29 Jun 2010 16:07 Thank you for your answer Ted, You are right, well, I do have my login form, but what I do not understand is how to implement switch statement.. switch ($level){ case 0: include ("admin.php"); break; case 1: include ("sales.php"); break; case 2: include ("superuser.php"); break; } Now I'm wondering if every page has to have something like: if ($level==2){ } else { } but, I think that might check link pages, and whole menu... Not, just the menu for admin as example. So, that's why I'm asking for help... I was saying just the idea to get example codes, to base on it, asking : how do I get to london?, not how do I drive a car? Thanks. Carlos Sura. > Date: Tue, 29 Jun 2010 15:58:10 -0400 > To: carlos_sura(a)hotmail.com; php-general(a)lists.php.net > From: tedd.sperling(a)gmail.com > Subject: Re: [PHP] Login form + User level access > > At 7:46 PM +0000 6/29/10, Carlos Sura wrote: > >Hello everyone. > > > >I have this question: I'm developing a login system but what I need > >is to do is access levels > > > >I mean, in my database I have this users: > > > >Admin > >Superusers > >sales > >purchase > >etc > > > >So, What I do basically need is, when a user from sales log in.. I > >want him to see just the menu from SALES, He cannot see others menu > >options, and he can't get access, I was reading that I can do that > >with Switch, but really I have no idea about it... Any help? > > > >Thank you. > > > >Carlos Sura. > > Carlos: > > That's a little like saying, "I want to build a car so I can drive > around the country. I was reading that I could do that with a key, > but I don't have any idea about it... Any help?" > > Yes, you can use a switch statement, but that just one control > structure in a much, much larger application. > > Cheers, > > tedd > > > -- > ------- > http://sperling.com http://ancientstones.com http://earthstones.com _________________________________________________________________ http://clk.atdmt.com/UKM/go/197222280/direct/01/ Do you have a story that started on Hotmail? Tell us now
From: tedd on 30 Jun 2010 09:54 At 8:07 PM +0000 6/29/10, Carlos Sura wrote: >Thank you for your answer Ted, You are right, well, I do have my >login form, but what I do not understand is how to implement switch >statement. > >switch ($level){ > >case 0: > >include ("admin.php"); > >break; > >case 1: > >include ("sales.php"); > >break; > >case 2: > >include ("superuser.php"); > >break; > >} Try: case 0: header('location:admin.php'); exit(); break; Instead of includes. >Now I'm wondering if every page has to have something like: > >if ($level==2){ > >} else { > >} Of course, you must check the level of permission granted to the user before allowing them to see any protected page. I would suggest using a $_SESSION['level'] during logon to set the level of permission and then on each protected page do something like this: $level = isset($_SESSION['level']) ? $_SESSION['level'] : null; if($level < 2) { // redirect to somewhere else header('location:admin.php'); exit(); } // this will allow the super-user (level 2) to see everything while redirecting everyone else elsewhere Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com
|
Pages: 1 Prev: [SOLVED]mail command failing Next: file_get_contents limit |