ycool11 Posted September 15, 2009 Share Posted September 15, 2009 I need help with some code, basically I'm trying to write a code that will redirect a user to a page based on his group membership. I am fairly new to php so sorry if i don;t make sense. This is what I have now, if the user belongs to Group 1 & 3 then dispay page or exit. if (!($check['team']=='Group 1') && !($check['team']=='Group 3')) { echo 'You are not allowed to access this page.'; exit(); } I need to modify the code and make it so if logged in user belongs to Group 1 then redirect to group1.php, if group2 redirect to group2.php, if group3 then redirect to group3.php, or exit. I was thinking of: if (!($check['team']=='Group 1')); Header ("Location: http://www.mysite.com/group1.php"); elseif (!($check['team']=='Group 2')); Header ("Location: http://www.mysite.com/group2.php"); else echo "You are not allowed to access this page."; exit(); } but it did not work. Link to comment https://forums.phpfreaks.com/topic/174282-solved-need-help/ Share on other sites More sharing options...
RussellReal Posted September 15, 2009 Share Posted September 15, 2009 if ($check['team'] == 'Group 1') { // include or w.e } elseif ($check['team'] == 'Group 2') { // whatever } elseif ($check['team'] == 'Group 3') { // whatever 2 } but you'd be better off with switch ($check['team']) { case 'Group 1': break; case 'Group 2': break; case 'Group 3': break; } Link to comment https://forums.phpfreaks.com/topic/174282-solved-need-help/#findComment-918721 Share on other sites More sharing options...
ycool11 Posted September 15, 2009 Author Share Posted September 15, 2009 SOLVED! THANK YOU! Link to comment https://forums.phpfreaks.com/topic/174282-solved-need-help/#findComment-918727 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.