_POST, _GET, _REQUEST -......

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
~john
Forum Newbie
Posts: 1
Joined: Wed Nov 13, 2002 11:40 am

_POST, _GET, _REQUEST -......

Post by ~john »

Hi I a real newbee to the PHP and I'm ashamed to say that I can't working this out so if someone would be kind enough to help me, Please.

My problem is that when I'm trying to transfere variables to a script they can't be found in either _POST, _GET, _REQUEST, _COCKIE, _SESSION
this is my index.html

<form action="action.php" method="POST">
<select name=fruit>
<option>Apple<option>Orange<option>Banana<option>Pear</select>
<input type=submit>
</form>

and this is the action.php
<html> <head> <title>phptest</title>
<body bgcolor=white>
<?
$fruits=$_POST['fruit'];
echo "Your choice $fruits<P>";
?>
</body></html>

The out put of this just shows "Your choice"
it doesn't matter what ever kind of fruit I choose, I can't see it.

Should probably mention that I'm running an Apache2 server
with PHP 4.3.0-pre2 on a WinXP machine.

PLEASE HELP ME! :?:
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Maybe Apache isn't passing the POST headers properly - if you send the information using the GET method can you access the result in $_GET['fruit']?

Mac
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

with the 4.3.preXYZ packages ships a test-suite (for windows, too?).
Maybe you should run these tests ;)
hairyjim
Forum Contributor
Posts: 219
Joined: Wed Nov 13, 2002 9:04 am
Location: Warwickshire, UK

Post by hairyjim »

I had a similar problem, but then I added quotes on the variable set line.

Like so...

$message = "$_POST[Suggestion]";

And then everything worked. Give it a try.

So where you have written $fruits=$_POST['fruit']; change it to $fruits="$_POST['fruit']";

Regards
James
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

what version of php are you running, if it is pre 4.1.0 then you will have to use the full $HTTP_POST_VARS['fruit'] to get the variable value!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

hairyjim wrote:I had a similar problem, but then I added quotes on the variable set line.

Like so...

$message = "$_POST[Suggestion]";

And then everything worked. Give it a try.

So where you have written $fruits=$_POST['fruit']; change it to $fruits="$_POST['fruit']";
Honestly this really shouldn't make any difference and

Code: Select all

$fruits = "$_POST&#1111;'fruit']";
will in fact cause a parse error. This

Code: Select all

$message = "$_POST&#1111;Suggestion]";
and

Code: Select all

$message = $_POST&#1111;'Suggestion'];
should work exactly the same.

If you have your error reporting up high and just use

Code: Select all

$message = $_POST&#1111;Suggestion];
you get an error message.

Mac
Post Reply