Home > Archive > PHP on Windows > May 2004 > RE: [PHP-WIN] I've found the cause of the error but I cant fix it.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
RE: [PHP-WIN] I've found the cause of the error but I cant fix it.
|
|
| Gerardo Rojas 2004-05-13, 1:30 pm |
| If you provide a bit of your source code. It would be quicker to =
determine the problem.
--
Gerardo S. Rojas
mailto: grojas@strategicinc.com
-----Original Message-----
From: Alejandro C=E9sar Garrammone [mailto:agarrammone@afip.gov.ar]
Sent: Wednesday, May 12, 2004 10: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
| |
| Trevor Gryffyn 2004-05-13, 1:30 pm |
| 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 =3D $_GET["variablename"];
Or...
$variablename =3D $_POST["variablename"];
Or..
$variablename =3D $_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 =3D =
$_POST["variablename"];
If (isset($_GET["variablename"])) $variablename =3D =
$_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=3D"index.php?GETVARIABLE=3Dtestget" method=3D"POST">
<input type=3D"text" name=3D"POSTVARIABLE" value=3D"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=E9sar Garrammone [mailto:agarrammone@afip.gov.ar]=20
> 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=20
> cant fix it.
>=20
>=20
> 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=20
> other hand, on the file referenced in the form, I put an echo=20
> with the variable, and it doesn't print it. (I use GET, on=20
> the link it shows it, but the variable is empty).
>=20
> How can I fix it?
>=20
> Best Regards,
>=20
> Alex
>=20
| |
| Alejandro césar garrammone 2004-05-13, 2:32 pm |
| I understands you well but the problem is a w ago with a OS Win98 all the
pages funcioned very well, but when I install WinXP, and configure the
mysql, apache and php and I tested with the same pages I've used on W98 it's
not working.
Where is the configuring problem?
If you need some of the files like php.ini and httpd.conf, tell me and I'll
send you those files.
Thxs for helping me!!!
Alex
----- Original Message -----
From: "Gryffyn, Trevor" <TGryffyn@air-cargo-inc.com>
To: <php-windows@lists.php.net>
Cc: "Alejandro César Garrammone" <agarrammone@afip.gov.ar>
Sent: Thursday, May 13, 2004 1:18 PM
Subject: RE: [PHP-WIN] I've found the cause of the error but I cant fix it.
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
>
| |
| Trevor Gryffyn 2004-05-13, 2:32 pm |
| It sounds like a fairly common problem. You probably want to check the =
entry in your PHP.INI file:
register_globals =3D Off
You might have had it turned ON before in which case you wouldn't have =
to use $_POST or $_GET to get the values of the variables, they're =
automatically assigned to whatever the $_POST or $_GET variable name is.
For security reasons, you really should set it to OFF (as illustrated =
above). Sample code/example follows:
------------- Before Reinstall (assuming "register_globals =3D ON") =
---------------
HTML:
<input type=3D"text" name=3D"testvariable" value=3D"50">
PHP:
Echo "Value of testvariable is: $testvariable";
Output: Value of testvariable is: 50
------------- After Reinstall (assuming "register_globals =3D OFF") =
----------
HTML:
<input type=3D"text" name=3D"testvariable" value=3D"50">
PHP:
Echo "Value of testvariable is: $testvariable";
Output: Value of testvariable is:
(no value is present in $testvariable because it's not automatically =
assigned when "register_globals" is turned off)
------------- After Reinstall ("register_globals =3D OFF") ----------
HTML:
<input type=3D"text" name=3D"testvariable" value=3D"50">
PHP:
$testvariable =3D $_REQUEST["testvariable"];
Echo "Value of testvariable is: $testvariable";
Output: Value of testvariable is: 50
(no value is present in $testvariable because it's not automatically =
assigned when "register_globals" is turned off)
Try something like that.
-TG
> -----Original Message-----
> From: Alejandro C=E9sar Garrammone [mailto:agarrammone@afip.gov.ar]=20
> Sent: Thursday, May 13, 2004 12:39 AM
> To: Gryffyn, Trevor
> Cc: php-windows@lists.php.net
> Subject: Re: [PHP-WIN] I've found the cause of the error but=20
> I cant fix it.
>=20
>=20
> I understands you well but the problem is a w ago with a=20
> OS Win98 all the pages funcioned very well, but when I install
> WinXP, and configure the mysql, apache and php and I tested with
> the same pages I've used on W98 it's not working.
> Where is the configuring problem?
>=20
> If you need some of the files like php.ini and httpd.conf,=20
> tell me and I'll send you those files.
>=20
> Thxs for helping me!!!
>=20
> Alex
> ----- Original Message -----
> From: "Gryffyn, Trevor" <TGryffyn@air-cargo-inc.com>
> To: <php-windows@lists.php.net>
> Cc: "Alejandro C=E9sar Garrammone" <agarrammone@afip.gov.ar>
> Sent: Thursday, May 13, 2004 1:18 PM
> Subject: RE: [PHP-WIN] I've found the cause of the error but=20
> I cant fix it.
>=20
>=20
> If you're used to running on a system with register_globals=20
> turned ON then
> you might run into a snag with something like this since the=20
> GET and POST
> values aren't automatically assigned to the variables you're=20
> trying to echo.
>=20
> You need to do:
>=20
> $variablename =3D $_GET["variablename"];
>=20
> Or...
>=20
> $variablename =3D $_POST["variablename"];
>=20
> Or..
>=20
> $variablename =3D $_REQUEST["variablename"];
>=20
>=20
> The last one (REQUEST) will populate the $variablename=20
> variable with either
> GET or POST data so can be used for either. I forget the=20
> order that it
> takes it though, I believe it essentially does:
>=20
> If (isset($_POST["variablename"])) $variablename =3D=20
> $_POST["variablename"];
> If (isset($_GET["variablename"])) $variablename =3D=20
> $_GET["variablename"];
>=20
> (or vice versa)
>=20
> So if both $_POST["variablename"] and $_GET["variablename"]=20
> are both set,
> then the data stored in the GET overwrites the POST data=20
> previously assigned
> to $variablename.
>=20
>=20
> It IS possible to pass both POST and GET data at the same time:
>=20
> <form action=3D"index.php?GETVARIABLE=3Dtestget" method=3D"POST">
> <input type=3D"text" name=3D"POSTVARIABLE" value=3D"testpost">
> </form>
>=20
>=20
> Var_dump($_REQUEST) will have both GETVARIABLE and POSTVARIABLE values
> ("testget" and "testpost" respectively) available where as=20
> $_GET only has
> the GETVARIABLE value ("testget") and $_POST only has the=20
> POSTVARIABLE value
> ("testpost")
>=20
> -TG
>=20
>=20
>=20
>=20
>=20
>=20
| |
| Steve Douville 2004-05-13, 2:32 pm |
| What versions of PHP are/were you running? The newest versions install with
globals not automatically being registered by default as opposed to the
older versions that by default registered globals. Perhaps that is the
problem, that you have an older version on 98 where globals are
automatically registered so your POST variables are available but in the
newest version you've installed on XP doesn't do that by default.
Check the register_globals variable in your phpinfo() output. Is it on or
off?
----- Original Message -----
From: "Alejandro César Garrammone" <agarrammone@afip.gov.ar>
To: "Gryffyn, Trevor" <TGryffyn@air-cargo-inc.com>
Cc: <php-windows@lists.php.net>
Sent: Thursday, May 13, 2004 12:38 AM
Subject: Re: [PHP-WIN] I've found the cause of the error but I cant fix it.
> I understands you well but the problem is a w ago with a OS Win98 all
the
> pages funcioned very well, but when I install WinXP, and configure the
> mysql, apache and php and I tested with the same pages I've used on W98
it's
> not working.
> Where is the configuring problem?
>
> If you need some of the files like php.ini and httpd.conf, tell me and
I'll
> send you those files.
>
> Thxs for helping me!!!
>
> Alex
> ----- Original Message -----
> From: "Gryffyn, Trevor" <TGryffyn@air-cargo-inc.com>
> To: <php-windows@lists.php.net>
> Cc: "Alejandro César Garrammone" <agarrammone@afip.gov.ar>
> Sent: Thursday, May 13, 2004 1:18 PM
> Subject: RE: [PHP-WIN] I've found the cause of the error but I cant fix
it.
>
>
> 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
>
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
|
|
|
|
|