Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/02/2012, 02:20
interweb2012
 
Fecha de Ingreso: noviembre-2011
Mensajes: 5
Antigüedad: 12 años, 5 meses
Puntos: 0
Pregunta php procesar formularios

hola, estoy aprendiendo php y estoy atorada con un ejercicio; en teoria deberia desplegarse un programa que revisa datos ingresados por un usuario, como: nombre, apellido etc, y validar y revisar la sintaxis predefinida en el programa. pero lo único que logro desplegar en la web es la última línea de "binvenida".
el codigo es el siguiente:

echo "<html>
<head><title>Empty fields</title></head>
<body>";

/* set up array with all the fields */
$arreglo_etiqueta = array ("primernombre"=>"primernombre:",
"segundonombre"=>"segundonombre:",
"apellido"=>"apellido:",
"calle"=>"calle:",
"cp"=>"cp:");

/* check each field except middle name for
blank fields */
foreach ($_POST as $field => $value)
{
if($field != "segundonombre")
{
if( $value == "" )
{
$arreglo_vacio[$field] = "vacio";
}
}
} // end of foreach loop for $_POST


/* if any fields were blank, display error message and
redisplay form */
if(@sizeof($arreglo_vacio) > 0) //blank fields are found
{
echo "<b>no lleno uno o más campos obligatorios. Debe digitar:</b><br>";
/* display list of missing information */
foreach($arreglo_etiqueta as $field => $value)
{
echo "&nbsp;&nbsp;&nbsp;{$arreglo_etiqueta[$field]}<br>";
}

/*volver a mostrar el formulario*/
$primernombre=trim (strip_tags($_POST['primernombre']));
$segundonombre=trim (strip_tags($_POST['segundonombre']));
$apellido=trim (strip_tags($_POST['apellido']));
$calle=trim (strip_tags($_POST['calle']));
$cp=trim (strip_tags($_POST['cp']));

echo"<p><hr>
<form action='$_SERVER[PHP_SELF]'
method='POST'>\n;
<center>
<table width='95%' border='0' cellspacing='0' cellpadding='2'>
<tr>
<td align='right'> <b> {$arreglo_etiqueta ['primernombre']}:
</br>
</td>
<td><input type='text' name='primernombre' size='65' maxlength='65' value=['$primernombre']>
</td>
</tr>
<tr>
<td align='right'><b>{$arreglo_etiqueta['segundonombre']}:
</br>
</td>
<td><input type='text' name='segundonombre' size='65' maxlength='65' value=['$segundonombre']>
</td>
</tr>
<tr>
<td align='right'><b>{$arreglo_etiqueta['apellido']}:
</br>
</td>
<td><input type='text' name='apellido' size='65' maxlength='65' value=['apellido']>
</td>
</tr>
<tr>
<td align='right'><b>{$arreglo_etiqueta['calle']}:
</br>
</td>
<td><input type='text' name='calle' size='65' maxlength='65' value=['calle']>
</td>
</tr>
<tr>
<td align='right'><b>{$arreglo_etiqueta['cp']}:
</br>
</td>
<td><input type='text' name='cp' size='65' maxlength='65' value=['cp']>
</td>
</tr>
</table>
<p> <input type='submit' value='enviar nombre y direccion'>

</form> </center>";
exit();
}

echo"BIENVENIDO";
?>

por favor ayuda deseperada!!