3

I'm trying to pass the variable $userhash to the url but for some reason it's not working. Here's my code:

header("Location: home.php?userhash=$userhash");

I know userhash has a value because I can echo it and see it if I comment out the header.

I tried doing something like this:

header("Location: home.php?userhash=test"); 

and also

header("Location: home.php?userhash='test'");

but each time I it redirects me to the next page the url always looks like this home.php?userhash=. What am I doing wrong?

2
  • do you have .htaccess? Post home.php code Commented Apr 8, 2013 at 19:32
  • 1
    not quite relevant, but syntactically header('Location: home.php?userhash='.$userhash); is better than header("Location: home.php?userhash=$userhash"); An exit; thereafter will also prevent any other code after that from running, however unlikely. Commented Apr 8, 2013 at 19:35

2 Answers 2

2

put an exit after the header

header('Location: /home.php?username='.$username);
exit;

http://php.net/manual/en/function.header.php check out the part about Location:

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks that worked. I almost figured out the problem, it's not in login but in my home.php, I think i'm setting the url variable to nothing. Thanks!
thanks i love kudos :p accept the answer if your question is really answered
1

Try this code

header("Location: home.php?userhash=".$userhash);
exit;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.