Foros del Web » Programando para Internet » PHP »

Consicionales

Estas en el tema de Consicionales en el foro de PHP en Foros del Web. Buenas. Este es mi primer problema. Tengo el sigiente problema. He realizado el siguiente condicional if/elseif/elfe: Código PHP: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>     <title>untitled</title>      ...
  #1 (permalink)  
Antiguo 19/03/2008, 08:50
 
Fecha de Ingreso: marzo-2008
Ubicación: Logroño
Mensajes: 4
Antigüedad: 16 años, 1 mes
Puntos: 0
Consicionales

Buenas. Este es mi primer problema.

Tengo el sigiente problema. He realizado el siguiente condicional if/elseif/elfe:

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <title>untitled</title>
    
</head>
<body bgcolor="chartreuse">
    <font face="arial" size="+1">
        <?php
        extract 
$_REQUEST ) ; //Se obtiene de la informacion de entrada
            
if ( ! isset ( $submit_fare ) | | $age == " " ) { 
                print 
"Debes de introducir tu edad!<br />";
                exit ;
            }
        
?>
        
<table border="1" cellpadding="10">
<tr bgcolor="azure">
    
    <?php
        
if ( $age && $age 13 ) {
            
$price 5.00;
            print 
"<td><b>You pay \$$price, the child's fare!</td>";
        } 
        elseif ( 
$age >= 13 && $age 55 ) {
            
$price 8.25;
            print 
"<td><b>You pay \$$price, regular adult fare!</td>";
        }
        elseif ( 
$age >= 55 && $age <= 120 ) {
            
$price 10.00;
            print 
"<td><b>You pay \$$price, the senior fare!</td>";
        }
        else {
            print 
"<td><b>You are not a human!</td>";
        }
    
?>
</body>
</html>
Lo que me ocurre es que el servidor me devuelve una pagina en blanco sin contenido alguno despues de mandarle la variable $age con un formulario html. Lo he repasado 3 veces, pero no veo el error. Otros ojos que me puedan informa de algo??? Muchas gracias.
  #2 (permalink)  
Antiguo 19/03/2008, 08:52
Avatar de spider_boy  
Fecha de Ingreso: diciembre-2003
Ubicación: Chile
Mensajes: 1.855
Antigüedad: 20 años, 4 meses
Puntos: 89
Re: Consicionales

Probaste utilizar $_REQUEST['age'] ó $_POST['age'] en vez de utilizar extract()?

Nos vemos.
  #3 (permalink)  
Antiguo 19/03/2008, 08:57
Avatar de hackteam  
Fecha de Ingreso: diciembre-2007
Mensajes: 67
Antigüedad: 16 años, 4 meses
Puntos: 0
Re: Consicionales

A mi modo de ver, y siendo novato de programacion, tu variable age se quedo "colgada" porque no veo de donde la extragiste, hubieras hecho
$age = $_REQUEST ['age'];

no conozco la funcion extract, pero si la guardaste ahi DONDE LA LLAMAS? siendo que extrae tus variables, deberia haberla guardado en un array y necesitas recorrerlo si ese es el caso para obtener las variables que necesitas :)
  #4 (permalink)  
Antiguo 19/03/2008, 09:02
 
Fecha de Ingreso: marzo-2008
Ubicación: Logroño
Mensajes: 4
Antigüedad: 16 años, 1 mes
Puntos: 0
Re: Consicionales

Cita:
Iniciado por spider_boy Ver Mensaje
Probaste utilizar $_REQUEST['age'] ó $_POST['age'] en vez de utilizar extract()?

Nos vemos.
Buenas: Me temo que todavia no he llegado a eso en mi libro de estudios.
  #5 (permalink)  
Antiguo 19/03/2008, 09:03
 
Fecha de Ingreso: marzo-2008
Ubicación: Logroño
Mensajes: 4
Antigüedad: 16 años, 1 mes
Puntos: 0
Re: Consicionales

Cita:
Iniciado por hackteam Ver Mensaje
A mi modo de ver, y siendo novato de programacion, tu variable age se quedo "colgada" porque no veo de donde la extragiste, hubieras hecho
$age = $_REQUEST ['age'];

no conozco la funcion extract, pero si la guardaste ahi DONDE LA LLAMAS? siendo que extrae tus variables, deberia haberla guardado en un array y necesitas recorrerlo si ese es el caso para obtener las variables que necesitas :)
Hola. La variable $age se la envio a traves de un formulario:

Código PHP:
<font face="arial" size="+1">
        <
form method="get" action="ejemplo7.2.php">

            <
p>Cuantos anos tienes?
                <
input type="text" name="age" sixe="2">
            </
p>
            <
input type="submit" name="submit_fare" value="Get Fare">
        </
form
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:25.