ReenKatak Posted June 18, 2008 Share Posted June 18, 2008 Hi everyone who is reading this post I need help what i am trying to do is once a user is logged in the system is able to know whether it is an admin, a staff or a student and show them their links respectively. I am tryin to put in 3 conditions in one. tried using else if but it doesn't seem to work. it only works when there is 2 conditions. *SIGH* if (isset($_SESSION['id'])) { if($_SESSION['isAdmin'] == 1) { showAdminHyperlinks(); } else ($_SESSION['isStaff'] == 1) { showStaffHyperlinks(); } } else { showStudentHyperlinks(); } ?> Really had a hard time figuring out. Need your opinions... Quote Link to comment https://forums.phpfreaks.com/topic/110774-help-me-please/ Share on other sites More sharing options...
Jabop Posted June 18, 2008 Share Posted June 18, 2008 <?php if (isset($_SESSION['id'])) { if($_SESSION['isAdmin'] == 1) { showAdminHyperlinks(); } elseif ($_SESSION['isStaff'] == 1) { showStaffHyperlinks(); } else { showStudentHyperlinks(); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/110774-help-me-please/#findComment-568305 Share on other sites More sharing options...
ReenKatak Posted June 19, 2008 Author Share Posted June 19, 2008 Hi Jabop, tried that but it shows the student hyperlinks even though i logged in as an admin. I guessed there's a missing 'else' for the first 'if'? Thanks tho' Reen. Quote Link to comment https://forums.phpfreaks.com/topic/110774-help-me-please/#findComment-569056 Share on other sites More sharing options...
waynew Posted June 19, 2008 Share Posted June 19, 2008 You cant put a condition in an else. If(condition) action Else if(condition) action Else action Quote Link to comment https://forums.phpfreaks.com/topic/110774-help-me-please/#findComment-569060 Share on other sites More sharing options...
waynew Posted June 19, 2008 Share Posted June 19, 2008 Could you show more code? Quote Link to comment https://forums.phpfreaks.com/topic/110774-help-me-please/#findComment-569062 Share on other sites More sharing options...
Gruzin Posted June 19, 2008 Share Posted June 19, 2008 <?php if ($_SESSION['isAdmin'] == 1) { showAdminHyperlinks(); } elseif ($_SESSION['isStaff'] == 1) { showStaffHyperlinks(); } else { showStudentHyperlinks(); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/110774-help-me-please/#findComment-569070 Share on other sites More sharing options...
waynew Posted June 19, 2008 Share Posted June 19, 2008 <?php session_start(); Maybe? Quote Link to comment https://forums.phpfreaks.com/topic/110774-help-me-please/#findComment-569074 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.