you may be wrestling with a register_globals problem...
when php is useing register_globals, it automatically maps anything 'posted' from a form or 'getted' from the url are mapped into variables of the name set.... as of the new versions of php this variable is turned off by default... register_globals also looks in may other places for variables including any cookies and the sessions and the environment....
you may be interested in a function like this.... which mimicks the functionality of register globals, but acts on a variable by variable basis...
/**
* find a variable if it exists in specified location
*
* looks in specified places, in specified order, to find the. return a default if not found in specified places.
* $username = findVar('username','SP','guest');
* the above statement means: look for the varible named username in the Session, then the form POST, if not found in either place then set username to 'guest'
*
* @param $var_name - string, mandatory. The name of the variable to look for. ( for $var1 you send "var1" )
* @param $order - string, optional, default:'ECSPG', restriction: arbitrarily ordered subset of 'ECSPG'.
* The order of places to look for the variable. First Come First Serve.
* NOTE: this works in opposite order as the register_globals setting as defined in your php.ini
* 'ECSPG' = look first for variables set in the local scope, than as environmental varibles if found, return them
* look for varibale in the cookie, if found there return it
* look for variable in the session, if found there returnit
* look for variable in the form POST, if found there return it
* look for variable in the GET query, if found there return it
* if not found yet, return whatever $default is set to
* @param $default - mixed, optional, default:NULL. if not found anywhere with $order, set return this thing.
*
* @return mixed, the found variable of $defualt.
*/
function findVar( $var_name, $order="ECSPG", $default=NULL )
{
foreach ( range(0,(strlen($order)-1)) as $i ) {
switch ( strtoupper($order{$i}) ) {
case 'E':
if ( isset($GLOBALS) && isset($GLOBALS[$var_name]) ) {
return $GLOBALS[$var_name];
} else if ( $result = getenv($var_name) ) {
return $result;
}
break;
case 'C':
if ( isset($_COOKIE) && isset($_COOKIE[$var_name]) ) {
return $_COOKIE[$var_name];
} else if ( isset($HTTP_COOKIE_VARS) && isset($HTTP_COOKIE_VARS[$var_name]) ) {
return $HTTP_COOKIE_VARS[$var_name];
}
break;
case 'S':
if ( isset($_SESSION) && isset($_SESSION[$var_name]) ) {
return $_SESSION[$var_name];
} else if ( isset($HTTP_SESSION_VARS) && isset($HTTP_SESSION_VARS[$var_name]) ) {
return $HTTP_SESSION_VARS[$var_name];
}
break;
case 'P':
if ( isset($_POST) && isset($_POST[$var_name]) ) {
return $_POST[$var_name];
} else if ( isset($HTTP_POST_VARS) && isset($HTTP_POST_VARS[$var_name]) ) {
return $HTTP_POST_VARS[$var_name];
}
break;
case 'G':
if ( isset($_GET) && isset($_GET[$var_name]) ) {
return $_GET[$var_name];
} else if ( isset($HTTP_GET_VARS) && isset($HTTP_GET_VARS[$var_name]) ) {
return $HTTP_GET_VARS[$var_name];
}
break;
}
}
return $default;
}