469,327 Members | 1,128 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

HTTP_POST and HTTP_GET_VARS

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
5 26732
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
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

[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
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
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.

Similar topics

2 posts views Thread by Ben Hall | last post: by
4 posts views Thread by Sims | last post: by
1 post views Thread by Chris Cox | last post: by
3 posts views Thread by danny | last post: by
reply views Thread by odysseyphotography | last post: by
3 posts views Thread by joboils | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.