Reputation: 906
I have a strange issue and could not find the reason.
I have url
http://example.com/cp/user_detail?userID=2
So If I print this code
print_r($_REQUST);
it should not print
Array ( [userID] => 2 ...... ?
But its printing this array
Array ( [userID] => 84ac17a3690b4ecd8c8abfba8687e750 [_pk_id_2_2fa0] =>
26c324a269691d77.1410515405.1.1410515405.1410515405. [__utma] =>
24293118.939351632.1410515405.1410515405.1410515405.1 [__utmz] =>
24293118.1410515405.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
[PHPSESSID] => 0394d01235809edd26422eedc400b6b5 )
Is it not strange?
I have a general function for getting get or post value
function chf($value)
{
if(isset($_REQUEST[$value]))
{
if(isset($_POST[$value]))
{
$value=$_POST[$value];
}
else
{
$value=$_REQUEST[$value];
}
$keywords=array();
$keywords=array('update','delete','select');
foreach($keywords as $key=>$val)
{
$value= str_replace($val,'',$value);
}
return $value;
}
else
{
return '';
}
}
How should I changed it so it gives me correct string values?
Upvotes: 0
Views: 198
Reputation: 401
If you want data from your URL you should use
print_r($_GET);
This wil give you an array like:
Array(
[userID] => 2
)
Upvotes: 1
Reputation: 1580
$_REQUEST includes cookies by default: http://php.net/manual/en/reserved.variables.request.php . The PHPSESSID, __utm* are cookies. If you want just the URL parameters use $_GET.
Upvotes: 1