Page 1 of 1
Problem with header()
Posted: Sun Aug 15, 2010 8:49 am
by bluearrow
I ve just found devnetwork while I was search for php developer forums in Google ! I'm new to php and hope someone can tell me how to do this.
I want to send a header like this.
header("Location: add_us_done.php?c=$candy")
what's the correct way to do this when register glob is off ?
Re: Problem with header()
Posted: Sun Aug 15, 2010 8:52 am
by PHPHorizons
Hello bluearrow,
Welcome to the forum
I'm not sure what register globals has to do with the code you have there. Can you provide more information?
Cheers
Re: Problem with header()
Posted: Sun Aug 15, 2010 8:55 am
by liamallan
does $candy have a value?
for example:
Code: Select all
$candy = $_POST['username'];
header("Location: members.php?user=$candy")
here, $candy has a value set, which is received from a form
Re: Problem with header()
Posted: Sun Aug 15, 2010 9:06 am
by PHPHorizons
Alrighty, the issue here is not the header at all. You're fine doing the header that way. You are right to ask about the value of $candy. Unless you know that you know that you absolutely have to have register globals on, never turn it on. Now, with register globals off, no variable (except for variables php automatically creates like $_SERVER, or $argv, etc) has a value before it is defined. Therefore, if you want to use a GET or POST for the key "candy", then you need to explicitly capture that user input like you did in your second post.
Cheers
Re: Problem with header()
Posted: Sun Aug 15, 2010 10:15 am
by bluearrow
Thank you guys. I found the problem. in receiving page I had used $_POST instead of S_REQUEST.
Thank again for super fast help !