Re: submit y PHP_SELF

From: Date: Mon, 21 Oct 2002 19:00:04 +0000
Subject: Re: submit y PHP_SELF
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-28208@lists.php.net to get a copy of this message
Prueba con $_POST[submit] Julio ----- Original Message ----- From: "Ale" <alekai@arnet.com.ar> To: <lista@phpes.com> Sent: Monday, October 21, 2002 12:05 PM Subject: [PHP-ES] submit y PHP_SELF Hola: Soy nuevo en el uso de PHP, y mientras estaba leyendo alguna documentación me encontré con el siguiente caso, en el cual se supone que la página devuelve información. El tema es que cuando yo lo ejecuto, el if($submit) evalúa a FALSE (es decir, $submit está en NULL), y nunca logro que entre por esa rama del if, por lo que nunca me devuelve la información requerida. Cuando quise crear un ejemplo de mi coleto, utilizando el mismo esquema if-else, con la variable $submit y utilizando PHP_SELF tengo el mismo problema (no pasa por la rama if del if-else, nunca lo hace). ¿Existe un problema en el código o tengo algun inconveniente en mi entorno? Estoy utilizando PHP 4.2.3 y Apache 2.0.43. Saludos y muchas gracias. @le <HTML> <HEAD> <TITLE>Booking Reservations</TITLE> </HEAD> <BODY> <?php if ($submit) { echo '<h3>Holiday Booking Reservations</h3>'; $Price=500; $StarModifier=1; $CityModifier=1; if ($Grade=="Three") { if ($Destination=="Barcelona") { $CityModifier=2; $Price = $Price * $CityModifier; echo "The cost for a week in $Destination is $Price"; } elseif ($Destination=="Vienna") { $CityModifier=3.5; $Price = $Price * $CityModifier; echo "The cost for a week in $Destination is $$Price"; } elseif ($Destination=="Prague") { $Price = $Price * $CityModifier; echo "The cost for a week in $Destination is $Price"; } else { echo ("You've not entered a value for destination, go back and do it again"); } } elseif ($Grade=="Four") { $StarModifier=2; if ($Destination=="Barcelona") { $CityModifier=2.5; $Price = $Price * $CityModifier * $StarModifier; echo "The cost for a week in $Destination is $Price"; } elseif ($Destination=="Vienna") { $CityModifier=4; $Price = $Price * $CityModifier * $StarModifier; echo 'The cost for a week in ".$Destination." is $".$Price."'; } elseif ($Destination=="Prague") { $Price = $Price * $CityModifier * $StarModifier; echo "The cost for a week in $Destination is $Price"; } else { echo ("You've not entered a value for destination, go back and do it again"); } } else { echo ("You've not entered a value for hotel grade, go back and do it again"); } } else { # BREAK OUT OF PHP HERE SO WE DO NOT HAVE TO ECHO EACH LINE ?> <b>Please complete the following form se we can calculate your cost</b><br> <FORM METHOD="POST" ACTION="<?=$PHP_SELF?>"> <?php #changed this line ?> Where do you want to go on holiday? <BR> <BR> <INPUT NAME="Destination" TYPE="Radio" VALUE="Prague"> Prague <BR> <INPUT NAME="Destination" TYPE="Radio" VALUE="Barcelona"> Barcelona <BR> <INPUT NAME="Destination" TYPE="Radio" VALUE="Vienna"> Vienna <BR> <BR> What grade of hotel do you want to stay at? <BR> <BR> <INPUT NAME="Grade" TYPE="Radio" VALUE="Three"> Three Star <BR> <INPUT NAME="Grade" TYPE="Radio" VALUE="Four"> Four Star <BR> <BR> <INPUT TYPE="submit" name="submit" value="Enter"> <?php #changed this line ?> </FORM> <?php # BREAK BACK INTO PHP HERE TO CLOSE THE ELSE STATEMENT } ?> </BODY> </HTML>

« previous php.general.es (#28208) next »