rmpotter Posted November 24, 2009 Share Posted November 24, 2009 Alright, so I have this code: <? if ($_SESSION['uid']!='programmer'){ header('Location: index.php');exit; } include_once ("header.php"); ?> even when the uid is 'programmer' it redirects me to index... I obviously don't want this to happen.. if the user ligged in successfully as programmer, I want him to go to the correct page. Can anyone please tell me why this is happening?URL - http://nait.jtlnet.com/~fpkj5v0r/index.phpUser: programmerPass: prog123After you login, you can see that the uid is programmer, because I output it to the screen (it's on the banner, beside Logout)Please help, I've been trying different things, and I'm stumped! Link to comment Share on other sites More sharing options...
Ingolme Posted November 24, 2009 Share Posted November 24, 2009 Try this instead: if ($_SESSION['uid']!='programmer') { if(isset($_SESSION['uid'])) { echo $_SESSION['uid']; }exit;} See what exactly is in there. Obviously, it is not 'programmer' if it is sending people away from the page. Link to comment Share on other sites More sharing options...
rmpotter Posted November 24, 2009 Author Share Posted November 24, 2009 Try this instead:if ($_SESSION['uid']!='programmer') { if(isset($_SESSION['uid'])) { echo $_SESSION['uid']; }exit;} See what exactly is in there. Obviously, it is not 'programmer' if it is sending people away from the page. Alright, so I replaced what I wrote, with what you wrote.. and the only difference between yours and mine was that yours outputted the session uid, which I actually have tried, to confirm what the uid was, and it outputted programmer every time. But regardless, I copied yours in, and I edited yours to be like this: /* if ($_SESSION['uid']!='programmer') { header('Location: index.php'); exit; }*/ if ($_SESSION['uid']!='programmer') { if(isset($_SESSION['uid'])) { echo $_SESSION['uid']; } header('Location: index.php'); exit; } so basically I just threw in the header redirection in so it did something.. and it worked... so I don't get it. what I just did was I made yours into mine... which is dumb, I know, but I've tried so many different things, that all I'm left with are dumb alternatives. So basically, I changed your code to this: if ($_SESSION['uid']!='programmer') { header('Location: index.php'); exit; } And that is EXACTLY like my code.. except it works. PHP does this to me sometimes, and stumps me how it fixes itself. I know, you probably think I'm missing something, but this is what happened. Anyways, thanks.. it seems to work, atleast for now. If it sporadically ends up stopping working, like it sporadically started working, I'll let you know though! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.