I've this function, which is the method of a class. I'm posting the
constructor of the class down below. For some reason, when I fill out
a form and hit submit, I'm not getting any values. Can someone tell me
why?
function getVar($var="pa ssword") {
// 05-08-03 - the important thing about this function is it reverses
PHP's built-in load
// order for variables. PHP usually loads COOKIE last, so if you've
a competing POST and
// COOKIE, the POST loses. This is nuts, in my opinion, if someone
just posted a form, you
// almost always want that to have top priority. And that is what
this function does.
// 05-27-03 - I just discovered user created globals go in a var
called $GLOBALS which has been around
// since PHP 3.0. Even though it is old, I'm putting it at the end,
partly for security, but also
// because it is auto-global and therefore belongs with the other
auto-globals.
if ($this->HTTP_POST_VA RS[$var]) {
$value = $this->HTTP_POST_VA RS[$var];
echo "here is the value of post vars: $value";
} elseif ($this->HTTP_GET_VAR S[$var]) {
$value = $this->HTTP_GET_VAR S[$var];
echo $value;
} elseif ($this->HTTP_ENV_VAR S[$var]) {
$value = $this->HTTP_ENV_VAR S[$var];
echo $value;
} elseif ($this->HTTP_SERVER_VA RS[$var]) {
$value = $this->HTTP_SERVER_VA RS[$var];
echo $value;
} elseif ($this->HTTP_COOKIE_VA RS[$var]) {
$value = $this->HTTP_COOKIE_VA RS[$var];
echo $value;
} elseif ($_POST[$var]) {
$value = $_POST[$var];
echo $value;
} elseif ($_GET[$var]) {
$value = $_GET[$var];
echo $value;
} elseif ($_ENV[$var]) {
$value = $ENV[$var];
echo $value;
} elseif ($_SERVER[$var]) {
$value = $_SERVER[$var];
echo $value;
} elseif ($_COOKIE[$var]) {
$value = $_COOKIE[$var];
echo $value;
} elseif ($GLOBALS[$var]) {
$value = $GLOBALS[$var];
echo $value;
}
return $value;
}
function McInputOutput() {
// 06-20-03 - the global keyword doesn't work inside of objects, and
so we must use this
// method to get these old variables. You might ask, "Why not just
go with the new Super
// Globals, like $_GET?" The answer is that I've installed this cms
on a suprising number of
// hosts running old versions of PHP that don't support the new auto
globals. So it is good
// to be backwards compatible.
$this->HTTP_SERVER_VA RS = $GLOBALS["HTTP_SERVER_VA RS"];
$this->HTTP_POST_VA RS = $GLOBALS["HTTP_POST_VARS "];
$this->HTTP_GET_VAR S = $GLOBALS["HTTP_GET_V ARS"];
$this->HTTP_COOKIE_VA RS = $GLOBALS["HTTP_COOKIE_VA RS"];
$this->HTTP_ENV_VAR S = $GLOBALS["HTTP_ENV_V ARS"];
$this->id = 1;
}
constructor of the class down below. For some reason, when I fill out
a form and hit submit, I'm not getting any values. Can someone tell me
why?
function getVar($var="pa ssword") {
// 05-08-03 - the important thing about this function is it reverses
PHP's built-in load
// order for variables. PHP usually loads COOKIE last, so if you've
a competing POST and
// COOKIE, the POST loses. This is nuts, in my opinion, if someone
just posted a form, you
// almost always want that to have top priority. And that is what
this function does.
// 05-27-03 - I just discovered user created globals go in a var
called $GLOBALS which has been around
// since PHP 3.0. Even though it is old, I'm putting it at the end,
partly for security, but also
// because it is auto-global and therefore belongs with the other
auto-globals.
if ($this->HTTP_POST_VA RS[$var]) {
$value = $this->HTTP_POST_VA RS[$var];
echo "here is the value of post vars: $value";
} elseif ($this->HTTP_GET_VAR S[$var]) {
$value = $this->HTTP_GET_VAR S[$var];
echo $value;
} elseif ($this->HTTP_ENV_VAR S[$var]) {
$value = $this->HTTP_ENV_VAR S[$var];
echo $value;
} elseif ($this->HTTP_SERVER_VA RS[$var]) {
$value = $this->HTTP_SERVER_VA RS[$var];
echo $value;
} elseif ($this->HTTP_COOKIE_VA RS[$var]) {
$value = $this->HTTP_COOKIE_VA RS[$var];
echo $value;
} elseif ($_POST[$var]) {
$value = $_POST[$var];
echo $value;
} elseif ($_GET[$var]) {
$value = $_GET[$var];
echo $value;
} elseif ($_ENV[$var]) {
$value = $ENV[$var];
echo $value;
} elseif ($_SERVER[$var]) {
$value = $_SERVER[$var];
echo $value;
} elseif ($_COOKIE[$var]) {
$value = $_COOKIE[$var];
echo $value;
} elseif ($GLOBALS[$var]) {
$value = $GLOBALS[$var];
echo $value;
}
return $value;
}
function McInputOutput() {
// 06-20-03 - the global keyword doesn't work inside of objects, and
so we must use this
// method to get these old variables. You might ask, "Why not just
go with the new Super
// Globals, like $_GET?" The answer is that I've installed this cms
on a suprising number of
// hosts running old versions of PHP that don't support the new auto
globals. So it is good
// to be backwards compatible.
$this->HTTP_SERVER_VA RS = $GLOBALS["HTTP_SERVER_VA RS"];
$this->HTTP_POST_VA RS = $GLOBALS["HTTP_POST_VARS "];
$this->HTTP_GET_VAR S = $GLOBALS["HTTP_GET_V ARS"];
$this->HTTP_COOKIE_VA RS = $GLOBALS["HTTP_COOKIE_VA RS"];
$this->HTTP_ENV_VAR S = $GLOBALS["HTTP_ENV_V ARS"];
$this->id = 1;
}
Comment