|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Switch Case code to redirect from a link based on session variable
I'm writing a web app (php/mysql) for a college with 29 departments. I have a login page which checks username and password against the DB and if it finds the user also pulls down an access_level variable:
$loginStrGroup = mysql_result($LoginRS,0,'access_level'); //declare two session variables and assign them $GLOBALS['MM_Username'] = $loginUsername; $GLOBALS['MM_UserGroup'] = $loginStrGroup; //register the session variables session_register("MM_Username"); session_register("MM_UserGroup"); Then, based upon the access_level stored in $loginStrGroup, I redirect the logged in user to one of five pages by means of a switch case expression: switch ($loginStrGroup) { case 1: header("Location: switchboard01.php"); break; case 2: header("Location: switchboard02.php"); break; case 3: header("Location: switchboard03.php"); break; case 4: header("Location: switchboard04.php"); break; case 5: header("Location: switchboard05.php"); } All that works perfectly. Here's my problem -- some pages in the app need to be shared by users with different access levels. On one such page I have a link back to the switchboard, but it's a hard-coded link and returns all users back to just one switchboard. How can I reference the session variable $loginStrGroup in such a way that any user who clicks the link will be sent back to his/her proper switchboard? I've tried a few variations in code but can't get it to work. Thanks. Jerry |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Switch Case code to redirect from a link based on session variable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|