RE: [PHP-WIN] I've found the cause of the error but I cant fix it.
| From: | Gryffyn, Trevor | Date: | Thu, 13 May 2004 16:18:48 +0000 |
| Subject: | RE: [PHP-WIN] I've found the cause of the error but I cant fix it. | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-23707@lists.php.net to get a copy of this message | ||
If you're used to running on a system with register_globals turned ON then you might run into a
snag with something like this since the GET and POST values aren't automatically assigned to
the variables you're trying to echo.
You need to do:
$variablename = $_GET["variablename"];
Or...
$variablename = $_POST["variablename"];
Or..
$variablename = $_REQUEST["variablename"];
The last one (REQUEST) will populate the $variablename variable with either GET or POST data so can
be used for either. I forget the order that it takes it though, I believe it essentially does:
If (isset($_POST["variablename"])) $variablename = $_POST["variablename"];
If (isset($_GET["variablename"])) $variablename = $_GET["variablename"];
(or vice versa)
So if both $_POST["variablename"] and $_GET["variablename"] are both set, then
the data stored in the GET overwrites the POST data previously assigned to $variablename.
It IS possible to pass both POST and GET data at the same time:
<form action="index.php?GETVARIABLE=testget" method="POST">
<input type="text" name="POSTVARIABLE" value="testpost">
</form>
Var_dump($_REQUEST) will have both GETVARIABLE and POSTVARIABLE values ("testget" and
"testpost" respectively) available where as $_GET only has the GETVARIABLE value
("testget") and $_POST only has the POSTVARIABLE value ("testpost")
-TG
> -----Original Message-----
> From: Alejandro César Garrammone [mailto:agarrammone@afip.gov.ar]
> Sent: Wednesday, May 12, 2004 11:48 PM
> To: php-windows@lists.php.net
> Subject: [PHP-WIN] I've found the cause of the error but I
> cant fix it.
>
>
> Hi all,
> The problem is the GET and the POST method.
> I've create a simple form and I pass my name on it, on the
> other hand, on the file referenced in the form, I put an echo
> with the variable, and it doesn't print it. (I use GET, on
> the link it shows it, but the variable is empty).
>
> How can I fix it?
>
> Best Regards,
>
> Alex
>