Page 1 of 1

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

Posted: Wed Nov 13, 2002 11:40 am
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! :?:

Posted: Thu Nov 14, 2002 3:22 am
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

Posted: Thu Nov 14, 2002 4:21 am
by volka
with the 4.3.preXYZ packages ships a test-suite (for windows, too?).
Maybe you should run these tests ;)

Posted: Thu Nov 14, 2002 4:26 am
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

Posted: Thu Nov 14, 2002 5:31 am
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!

Posted: Thu Nov 14, 2002 5:46 am
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