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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to