PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 8th, 2005, 09:22 PM
massiej massiej is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 3 massiej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 34 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Switch Case code to redirect from a link based on session variable


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT