Jump to content

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


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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...