Page 1 of 1
Getting values from $_POST[''] or $_GET[''] problem ??
Posted: Wed Jan 10, 2007 7:50 pm
by PHPycho
Hello everybody
is there anyway to get the values from the $_POST[] or $_GET[] from the single varibale ?
if anybody knows plz just jott it down..
Posted: Wed Jan 10, 2007 8:05 pm
by Begby
What on earth are you talking about?
get the values from $_POST or $_GET from the single variable?
Please clarify.
Posted: Wed Jan 10, 2007 8:08 pm
by Christopher
Take a look in the manual at $_REQUEST.
Posted: Thu Jan 11, 2007 1:22 am
by dibyendrah
Yes, GPC variables i.e; $_GET, $_POST, and $_COOKIE are accessible through $_REQUEST
Posted: Thu Jan 11, 2007 2:12 am
by RobertGonzalez
$_REQUEST does not come without it's issues. If you know something is coming from POST, use POST, and so on for all the superglobals.
Posted: Thu Jan 11, 2007 4:33 am
by dibyendrah
Suppose, we have variable x for all GPC.
Code: Select all
<?php
$_POST['x']=1;
$_GET['x']=2;
$_COOKIE['x']=3;
?>
What will $_REQUEST['x'] will have now? Sorry, I have not tried that yet.
Posted: Thu Jan 11, 2007 5:14 am
by brendandonhue
I'm not sure what will happen with the cookie value, but you can't have both POST and GET in one HTTP request. Take a look at $_SERVER['REQUEST_METHOD']
Posted: Thu Jan 11, 2007 10:03 am
by feyd
brendandonhue wrote:I'm not sure what will happen with the cookie value, but you can't have both POST and GET in one HTTP request.
I beg to differ.
Code: Select all
<form action="?foo=bar" method="post">
<input name="bar" value="foo" />
<input type="submit" value="Submit" />
</form>
Posted: Thu Jan 11, 2007 10:39 am
by RobertGonzalez
brendandonhue wrote:I'm not sure what will happen with the cookie value, but you can't have both POST and GET in one HTTP request. Take a look at $_SERVER['REQUEST_METHOD']
You can have $_GET, $_POST, $_SESSION and $_COOKIE all in one request.
To answer the question about which comes where, try this...
Code: Select all
<?php
if (isset($_POST['send_form']))
{
echo '<h1>The Request value is: ' . $_REQUEST['foo'] . '</h1>';
}
setcookie('foo', 'cookieval');
?>
<form method="post" action="<?php echo basename($_SERVER['SCRIPT_FILENAME']); ?>?foo=getval">
<input type="text" name="foo" value="postval" />
<input type="submit" name="send_form" value="Check the Request value" />
</form>
I think there is an order to the GPCS array and the order I think is set in php.ini.
Posted: Thu Jan 11, 2007 4:43 pm
by PHPycho
what about ini_set() , is this the solution ?
Posted: Thu Jan 11, 2007 5:07 pm
by feyd
ini_set() will not affect the setting early enough.
http://php.net/ini.core#ini.variables-order
Posted: Thu Jan 11, 2007 5:33 pm
by PHPycho
so whats the solution then?
do i have to check which is set using isset($_GET['x']) OR isset($_POST['x']) to get the approrialte value
or there is alternative that uses a special function ?
Once again interrupting Devnetworkians
Posted: Thu Jan 11, 2007 5:43 pm
by feyd
Find the directive in
http://php.net/manual/en/ini.php
It lists where it can be altered. If you don't understand the constant, look at the bottom of the page.
You have a private message to read PHPycho.