By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,712 Members | 1,432 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,712 IT Pros & Developers. It's quick & easy.

HTTP_POST and HTTP_GET_VARS

P: n/a
I am a beggining PHP developer (been doing it for like 3 weeks now)
and I am currently having a problem getting these arrays to work. I am
running PHP 4.3.4 with Apache 2.0.47 on WinXP. I have a pretty good
idea as to how they work, but no clue on how to apply them to the PHP
scripts that I have written. (I'm not sure how to code it in properly,
and have been stuck on this problem for a few days now) Could some one
please advise me on this matter? (preferably soon?!?) Due to the
differences I have spotted amongst the versions of PHP out there, I am
not sure what the format is for the code.
~Greatful for any help!
~Phry
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Phrylock wrote:
I am a beggining PHP developer (been doing it for like 3 weeks now)
and I am currently having a problem getting these arrays to work. I am
running PHP 4.3.4 with Apache 2.0.47 on WinXP.

[snip]

The manual is your first stop:

<URL:http://www.php.net/manual/en/reserved.variables.php>
<URL:http://www.php.net/manual/en/language.variables.predefined.php>

Basically, $HTTP_POST_VARS[] is just a normal array that is initially
populated by PHP, and $_POST[] is a "superglobal". Don't bother using
$HTTP_POST_VARS[] unless you absolutely have to use an old version of PHP
or something. The same applies to the other predefined arrays such as
$_GET[] and $HTTP_GET_VARS[].

For example:

<?php

echo(htmlentities($_REQUEST['foo']));

?>
--
Jim Dabell

Jul 17 '05 #2

P: n/a
So, let say I have an HTML page with drop menus, text boxes, and a
submit button. 1 menu is for selecting a species of wood (6 types for
my purposes), thus 6 options and the variable is known as Species, the
next menu is size, and there are 24 options there (variable name =
size), then the next thing is a text box for quantity to order,
numeric, (variable = qty), then finally the user has to select a state
to add the corresponding state taxes, (Variable= State), how do I get
these variables to be read in PHP 4.3.4 then, without using the affor
mentioned Array methods?

Thanks,
Andy

Jim Dabell <ji********@jimdabell.com> wrote in message news:<fP********************@giganews.com>...
Phrylock wrote:
I am a beggining PHP developer (been doing it for like 3 weeks now)
and I am currently having a problem getting these arrays to work. I am
running PHP 4.3.4 with Apache 2.0.47 on WinXP.

[snip]

The manual is your first stop:

<URL:http://www.php.net/manual/en/reserved.variables.php>
<URL:http://www.php.net/manual/en/language.variables.predefined.php>

Basically, $HTTP_POST_VARS[] is just a normal array that is initially
populated by PHP, and $_POST[] is a "superglobal". Don't bother using
$HTTP_POST_VARS[] unless you absolutely have to use an old version of PHP
or something. The same applies to the other predefined arrays such as
$_GET[] and $HTTP_GET_VARS[].

For example:

<?php

echo(htmlentities($_REQUEST['foo']));

?>

Jul 17 '05 #3

P: n/a

[Please don't post upside-down]

Phrylock wrote:
Jim Dabell <ji********@jimdabell.com> wrote in message
news:<fP********************@giganews.com>... [snip]
Basically, $HTTP_POST_VARS[] is just a normal array that is initially
populated by PHP, and $_POST[] is a "superglobal". Don't bother using
$HTTP_POST_VARS[] unless you absolutely have to use an old version of PHP
or something. The same applies to the other predefined arrays such as
$_GET[] and $HTTP_GET_VARS[].

[snip] So, let say I have an HTML page with drop menus, text boxes, and a
submit button. 1 menu is for selecting a species of wood (6 types for
my purposes), thus 6 options and the variable is known as Species, the
next menu is size, and there are 24 options there (variable name =
size), then the next thing is a text box for quantity to order,
numeric, (variable = qty), then finally the user has to select a state
to add the corresponding state taxes, (Variable= State), how do I get
these variables to be read in PHP 4.3.4 then, without using the affor
mentioned Array methods?


Use the $_REQUEST[] like I showed you in the example. It's just an array
you can access from anywhere in your scripts. It is populated by PHP
automatically, you don't have to worry about getting the values into the
array, you just have to use it. For instance:

index.html:

[...]
<form action="process.php" method="post">
<input type="text" name="qty">
<input type="submit">
</form>
[...]

process.php:

[...]
<?php

echo('You ordered ' . htmlentities($_REQUEST['qty']) . ' items.');

?>
[...]

--
Jim Dabell

Jul 17 '05 #4

P: n/a
Jim Dabell <ji********@jimdabell.com> wrote in message news:<DP********************@giganews.com>...
[Please don't post upside-down]

Phrylock wrote:
Jim Dabell <ji********@jimdabell.com> wrote in message
news:<fP********************@giganews.com>...

[snip]
Basically, $HTTP_POST_VARS[] is just a normal array that is initially
populated by PHP, and $_POST[] is a "superglobal". Don't bother using
$HTTP_POST_VARS[] unless you absolutely have to use an old version of PHP
or something. The same applies to the other predefined arrays such as
$_GET[] and $HTTP_GET_VARS[].

[snip]
So, let say I have an HTML page with drop menus, text boxes, and a
submit button. 1 menu is for selecting a species of wood (6 types for
my purposes), thus 6 options and the variable is known as Species, the
next menu is size, and there are 24 options there (variable name =
size), then the next thing is a text box for quantity to order,
numeric, (variable = qty), then finally the user has to select a state
to add the corresponding state taxes, (Variable= State), how do I get
these variables to be read in PHP 4.3.4 then, without using the affor
mentioned Array methods?


Use the $_REQUEST[] like I showed you in the example. It's just an array
you can access from anywhere in your scripts. It is populated by PHP
automatically, you don't have to worry about getting the values into the
array, you just have to use it. For instance:

index.html:

[...]
<form action="process.php" method="post">
<input type="text" name="qty">
<input type="submit">
</form>
[...]

process.php:

[...]
<?php

echo('You ordered ' . htmlentities($_REQUEST['qty']) . ' items.');

?>
[...]


Thanks Man! I will try this first thing monday morning. Hopefully it
leads me somewhere, will keep you posted!
Jul 17 '05 #5

P: n/a
Hey,
Good news! I finally got it to work, and work well for me... Thanks
for all your help.

~Phry

no*****@norwaymi.com (Phrylock) wrote in message news:<dc**************************@posting.google. com>...
Jim Dabell <ji********@jimdabell.com> wrote in message news:<DP********************@giganews.com>...
[Please don't post upside-down]

Phrylock wrote:
Jim Dabell <ji********@jimdabell.com> wrote in message
news:<fP********************@giganews.com>... [snip]> Basically, $HTTP_POST_VARS[] is just a normal array that is initially
> populated by PHP, and $_POST[] is a "superglobal". Don't bother using
> $HTTP_POST_VARS[] unless you absolutely have to use an old version of PHP
> or something. The same applies to the other predefined arrays such as
> $_GET[] and $HTTP_GET_VARS[]. [snip] So, let say I have an HTML page with drop menus, text boxes, and a
submit button. 1 menu is for selecting a species of wood (6 types for
my purposes), thus 6 options and the variable is known as Species, the
next menu is size, and there are 24 options there (variable name =
size), then the next thing is a text box for quantity to order,
numeric, (variable = qty), then finally the user has to select a state
to add the corresponding state taxes, (Variable= State), how do I get
these variables to be read in PHP 4.3.4 then, without using the affor
mentioned Array methods?


Use the $_REQUEST[] like I showed you in the example. It's just an array
you can access from anywhere in your scripts. It is populated by PHP
automatically, you don't have to worry about getting the values into the
array, you just have to use it. For instance:

index.html:

[...]
<form action="process.php" method="post">
<input type="text" name="qty">
<input type="submit">
</form>
[...]

process.php:

[...]
<?php

echo('You ordered ' . htmlentities($_REQUEST['qty']) . ' items.');

?>
[...]


Thanks Man! I will try this first thing monday morning. Hopefully it
leads me somewhere, will keep you posted!

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.