Jump to content

Header() Redirecting Me Even If It Shouldn't...


rmpotter
 Share

Recommended Posts

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

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.

Edited by Ingolme
Link to comment
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...