jerry89 Posted February 23, 2009 Share Posted February 23, 2009 hey.. I have posted few days ago post , about user access lvl.. I have get good fedback... but heres come other problem now .. When i include the php code in, it wont redirect, it just pass to the admin page. I am including the login.php file. and this is the code i m using if ($user == 'admin') { header('Location: http://localhost/staff.php'); elseif ($user == 'client') { header('Location: http://localhost/client/client.php'); elseif ($user == 'guest') { header('Location: http://localhos/guest/guest.php'); }else { header('Location: http://localhost/index.php'); } exit; hope you can help.. if you need to more know , just PM or ask.. thanks [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/146510-user-lvl-redirect/ Share on other sites More sharing options...
premiso Posted February 23, 2009 Share Posted February 23, 2009 That code is missing some brackets, leave the mall off or keep them all on. if ($user == 'admin') { header('Location: http://localhost/staff.php'); }elseif ($user == 'client') { header('Location: http://localhost/client/client.php'); }elseif ($user == 'guest') { See if that gets you your redirect. Quote Link to comment https://forums.phpfreaks.com/topic/146510-user-lvl-redirect/#findComment-769190 Share on other sites More sharing options...
jerry89 Posted February 23, 2009 Author Share Posted February 23, 2009 no it still doesnt work... its just hang on login.php... and I have to refrest to to be able to get inthe staff.php any idea what else could be wrong... check the login.php and tell me where would you put the code, or any other suggestinos please thansk alot Quote Link to comment https://forums.phpfreaks.com/topic/146510-user-lvl-redirect/#findComment-769230 Share on other sites More sharing options...
sloth456 Posted February 23, 2009 Share Posted February 23, 2009 Read up on the header command: http://uk.php.net/header Take note of what it says: Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file. Quote Link to comment https://forums.phpfreaks.com/topic/146510-user-lvl-redirect/#findComment-769298 Share on other sites More sharing options...
jerry89 Posted February 24, 2009 Author Share Posted February 24, 2009 to be honest I dont think I have problem with the header.... I think i might have something else wrong.. I think of a "session.php" hmm which makes me wonder does need to be inside.."session" something about user lvl ? " IF so could you please help? I am newbie to php.. but i learn fast. Quote Link to comment https://forums.phpfreaks.com/topic/146510-user-lvl-redirect/#findComment-769942 Share on other sites More sharing options...
sloth456 Posted March 2, 2009 Share Posted March 2, 2009 I downloaded your login.php It's quite clear that you've not used the header command properly, because you've already outputed content to the page. The header command can only be used before you output any content. Quote Link to comment https://forums.phpfreaks.com/topic/146510-user-lvl-redirect/#findComment-774741 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.