Page 1 of 1
Question about GET and POST vars...
Posted: Fri Jul 29, 2005 3:41 pm
by _mike_
Hello, I have looked, but haven't been able to find a coherent answer on my question anywhere, so I ask ik here, in the hope any of you know an answer to my question.
Here it goes,
I know there is the $_GET and the $_POST vars to get the values... my question is, is there a global var that includes the values from both $_GET and $_POST? because my website has $_POST and $_GET variables to access several pages on the same way, and I'd hate to have to double code all the if statements.
Already thanks for your time,
Michael
Posted: Fri Jul 29, 2005 4:15 pm
by _mike_
Never mind, I've built my own solution, thanks anyways if you've thought about it.
Michael
Code: Select all
function getvar($name)
{
if(IsSet($_GETї$name]))
{
$ret = $_GETї$name];
}
if(IsSet($_POSTї$name]))
{
$ret = $_POSTї$name];
}
return $ret;
}
Posted: Fri Jul 29, 2005 4:39 pm
by bokehman
Yes there is. $_REQUEST contains the outputs of $_GET, $_POST and $_COOKIE
Posted: Fri Jul 29, 2005 5:35 pm
by _mike_
mmm, thanks, I thought of another way though... delved a bit into the phpbb code to figure out hehe.
Code: Select all
$_VAR = array_merge($HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS, $HTTP_SESSION_VARS, $HTTP_ENV_VARS, $HTTP_POST_FILES);
Then I have everything I need in one.
Thanks for your help anyways.
Michael
Posted: Fri Jul 29, 2005 5:41 pm
by Ambush Commander
Hmm... you don't seem to understand exactly how superglobals work...
http://us2.php.net/manual/en/language.v ... perglobals
Your code should be:
Code: Select all
$_VAR = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_SESSION, $_ENV, $_FILES);
But I don't think it does exactly what you want it to (once again, read the link above)
Once again, $_REQUEST is the same as merging GET POST and COOKIE but without the overhead of calling a function, so it's faster.
Just because it works doesn't mean it's the best solution.
Posted: Fri Jul 29, 2005 6:17 pm
by _mike_
true, but thing is, my page is merged with the phpbb code, and I really don't wish to learn the phpbb code from my head, to know what does what, and my solution works atm, I took it from the phpbb code directly...
It works, my site is secure, I'm happy
Thanks though for your replies
Michael
Posted: Fri Jul 29, 2005 7:45 pm
by timvw
LOL. phpbb and secure in one sentence.