Helpful Information
 
 
Category: PHP Development
help with GET VARS??

Setup: I have a url that is called like www.company.com/main.php3?id=12 (http://www.company.com/main.php3?id=12) and I need to read the value of id inside the main.php3 file.

Problem: I don't know if the person who typed the url in used upper, lower, or mised case when spelling 'ID'. And $ID, $id, $Id are all different variables.

Question: How do I get a case-insensitive var name to use?? or how do I determine the case. Do I have to use GET_VARS and loop through each var passed looking for the one i want?

Well, there isn't such a thing as a case-insensitive variable name. You have absolutely no control over how it's accessed? Isn't it coming from a link?

If you can't control it, you'll have to set up an if structure checking each possible way that they could have entered it. Major PITA.

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by kivey:
Setup: I have a url that is called like www.company.com/main.php3?id=12 (http://www.company.com/main.php3?id=12) and I need to read the value of id inside the main.php3 file.

Problem: I don't know if the person who typed the url in used upper, lower, or mised case when spelling 'ID'. And $ID, $id, $Id are all different variables.

Question: How do I get a case-insensitive var name to use?? or how do I determine the case. Do I have to use GET_VARS and loop through each var passed looking for the one i want?[/quote]

I don't know if this will work (I'm a newbie)
but you could turn all the $HTTP_GET_VARS int o lower case. Include this in a file called:
common.inc

// declre the request array
$arr_request = array();

//move the parameters to the request array

if (count($HTTP_GET_VARS)) {
while (list($key, $value) = each ($HTTP_GET_VARS)) {
$arr_request[strtolower($key)] = $value;
}
}

You can do the same for post. It turns all the requests to lower case under the $arr_request['request name']

If you have already written a large application, this may be a titious task.

Again, I am a newbie so this might not work.
Please e-mail and tell me how it goes.

-Jerome

Good one, Jer!










privacy (GDPR)