473,408 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

function for capturing form input won't return anything

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="password") {
// 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_VARS[$var]) {
$value = $this->HTTP_POST_VARS[$var];
echo "here is the value of post vars: $value";
} elseif ($this->HTTP_GET_VARS[$var]) {
$value = $this->HTTP_GET_VARS[$var];
echo $value;
} elseif ($this->HTTP_ENV_VARS[$var]) {
$value = $this->HTTP_ENV_VARS[$var];
echo $value;
} elseif ($this->HTTP_SERVER_VARS[$var]) {
$value = $this->HTTP_SERVER_VARS[$var];
echo $value;
} elseif ($this->HTTP_COOKIE_VARS[$var]) {
$value = $this->HTTP_COOKIE_VARS[$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_VARS = $GLOBALS["HTTP_SERVER_VARS"];
$this->HTTP_POST_VARS = $GLOBALS["HTTP_POST_VARS"];
$this->HTTP_GET_VARS = $GLOBALS["HTTP_GET_VARS"];
$this->HTTP_COOKIE_VARS = $GLOBALS["HTTP_COOKIE_VARS"];
$this->HTTP_ENV_VARS = $GLOBALS["HTTP_ENV_VARS"];

$this->id = 1;
}
Jul 16 '05 #1
5 2906
sam
Use the function isset to test if a variable is set :

if(isset($this->HTTP_POST_VARS[$var]))
{

}
elseif(isset($this->HTTP_GET_VARS[$var]))
{

}
.........

Hope this helps
lk******@geocities.com (lawrence) wrote in message news:<da**************************@posting.google. com>...
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="password") {
// 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_VARS[$var]) {
$value = $this->HTTP_POST_VARS[$var];
echo "here is the value of post vars: $value";
} elseif ($this->HTTP_GET_VARS[$var]) {
$value = $this->HTTP_GET_VARS[$var];
echo $value;
} elseif ($this->HTTP_ENV_VARS[$var]) {
$value = $this->HTTP_ENV_VARS[$var];
echo $value;
} elseif ($this->HTTP_SERVER_VARS[$var]) {
$value = $this->HTTP_SERVER_VARS[$var];
echo $value;
} elseif ($this->HTTP_COOKIE_VARS[$var]) {
$value = $this->HTTP_COOKIE_VARS[$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_VARS = $GLOBALS["HTTP_SERVER_VARS"];
$this->HTTP_POST_VARS = $GLOBALS["HTTP_POST_VARS"];
$this->HTTP_GET_VARS = $GLOBALS["HTTP_GET_VARS"];
$this->HTTP_COOKIE_VARS = $GLOBALS["HTTP_COOKIE_VARS"];
$this->HTTP_ENV_VARS = $GLOBALS["HTTP_ENV_VARS"];

$this->id = 1;
}

Jul 16 '05 #2
rb*****@caramail.com (sam) wrote in message news:<fd**************************@posting.google. com>...
Use the function isset to test if a variable is set :

if(isset($this->HTTP_POST_VARS[$var]))
{

}
elseif(isset($this->HTTP_GET_VARS[$var]))
{

}

I don't understand how this could much improve things, though I do
understand that in some technical sense it is better syntax for the
test I want to do. Perhaps I'll try it when I've spare time today.

However, you miss the main thing I'm curious about: as a function in
procedural code, this function works well and has never failed me. Now
that I'm trying to make it the method of an object, it has stopped
working. I'm looking for something that is specific to the object that
would cause it not to work. I've already checked what I thought was
obvious: do the variables have scope here, am I using the "$this->"
syntax. It seems I've done all that, yet the code won't work, and, as
I say, it works well as a function outside of this class.

For now, I've gone back to using getVar, the function, rather than
$io->getVar, the class method. But as I'm moving to OO, I'd like to
figure out how to make this function work as a class method.



........

Hope this helps
lk******@geocities.com (lawrence) wrote in message news:<da**************************@posting.google. com>...
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="password") {
// 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_VARS[$var]) {
$value = $this->HTTP_POST_VARS[$var];
echo "here is the value of post vars: $value";
} elseif ($this->HTTP_GET_VARS[$var]) {
$value = $this->HTTP_GET_VARS[$var];
echo $value;
} elseif ($this->HTTP_ENV_VARS[$var]) {
$value = $this->HTTP_ENV_VARS[$var];
echo $value;
} elseif ($this->HTTP_SERVER_VARS[$var]) {
$value = $this->HTTP_SERVER_VARS[$var];
echo $value;
} elseif ($this->HTTP_COOKIE_VARS[$var]) {
$value = $this->HTTP_COOKIE_VARS[$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_VARS = $GLOBALS["HTTP_SERVER_VARS"];
$this->HTTP_POST_VARS = $GLOBALS["HTTP_POST_VARS"];
$this->HTTP_GET_VARS = $GLOBALS["HTTP_GET_VARS"];
$this->HTTP_COOKIE_VARS = $GLOBALS["HTTP_COOKIE_VARS"];
$this->HTTP_ENV_VARS = $GLOBALS["HTTP_ENV_VARS"];

$this->id = 1;
}

Jul 16 '05 #3
Hi lawrence!

On 10 Jul 2003 11:11:11 -0700, lk******@geocities.com (lawrence)
wrote:
rb*****@caramail.com (sam) wrote in message news:<fd**************************@posting.google. com>...
Use the function isset to test if a variable is set :

if(isset($this->HTTP_POST_VARS[$var]))
{

}
elseif(isset($this->HTTP_GET_VARS[$var]))
{

}

I don't understand how this could much improve things, though I do
understand that in some technical sense it is better syntax for the
test I want to do. Perhaps I'll try it when I've spare time today.

You always have to check, if a variable has a value at all and then,
if the value is within range of the values you expect.
However, you miss the main thing I'm curious about: as a function in
procedural code, this function works well and has never failed me. Now
that I'm trying to make it the method of an object, it has stopped
working. I'm looking for something that is specific to the object that
would cause it not to work. I've already checked what I thought was
obvious: do the variables have scope here, am I using the "$this->"
syntax. It seems I've done all that, yet the code won't work, and, as
I say, it works well as a function outside of this class.
I only see you using $HTTP_POST_VARS witthout global. You can only do
that with $_POST, which is superglobal. MAybe thats the problem.


For now, I've gone back to using getVar, the function, rather than
$io->getVar, the class method. But as I'm moving to OO, I'd like to
figure out how to make this function work as a class method.

HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 16 '05 #4
On Sun, 13 Jul 2003 15:24:36 -0500, Jochen Daum wrote:

I only see you using $HTTP_POST_VARS witthout global. You can only do
that with $_POST, which is superglobal. MAybe thats the problem.


What is a superglobal?

Jul 16 '05 #5
On Tue, 15 Jul 2003 00:02:04 -0500, Jochen Daum wrote:
What is a superglobal?


A variable which is available in all functions and outside as well.
Check out www.php.net

HTH, Jochen


Thanks Jochen

Jul 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: TG | last post by:
Dear PHP Group, I have two forms that are used to collect user information. The first one takes user inputted values such as fullname, city, address etc. I want these values to display in the...
9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
7
by: JDS | last post by:
Hi, all. I'd like to do the following, preferably *without* resorting to JavaScript: I have a long, dynamically-generated form questionnaire. Not all of the form fields are dynamically...
3
by: Fabian | last post by:
I have created a javascript to manipulate a text strong given to it. It works in all the situations I put it in. Now, I want to create a form based interface. Essentially, the use types in the text...
10
by: Andrew | last post by:
Hi, I have a messagebox that pops up due to an event. I did it in javascript. ie. alert("Time's up. Assessment Ended"); I want to capture the OK and Cancel events of this alert messagebox. My...
5
by: mike | last post by:
If I have a document like: <script> function mike_test() {alert('hi');} </script> <iframe src="blank.html" id="my_iframe1"> </iframe> and in blank.html I have:
10
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get...
4
by: roohbir | last post by:
Hello, I need help with the following code. Would be very grateful for comments. I have a function called emailValid, and it is supposed to alert the user if h/she leaves the field blank. I want...
13
by: Andrew Falanga | last post by:
HI, Just a warning, I'm a javascript neophyte. I'm writing a function to validate the contents of a form on a web page I'm developing. Since I'm a neophyte, this function is quite simple at...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.