sábado, 23 de julio de 2011

Validar datos desde Servidor

Archivo .php :

Proceso Validar Formulario lado SERVER

// CREAR MENSAJE PREDETERMINADO
$mensaje = "ATENCION!!!...
\n";
$error = false;
// CAPTURAR DATOS DEL FORMULARIO
$Nombre = $_POST["NOM"];
$Direccion = $_POST["DIR"];
$Telefono = $_POST["TEL"];
// VALIDAR DATOS
if ($Nombre=="") {
$mensaje = $mensaje . "Ingrese Nombre
\n";
$error = true;
} // endif
if ($Direccion=="") {
$mensaje = $mensaje . "Ingrese Dirección
\n";
$error = true;
} // endif
if ($Telefono=="" || $Telefono=="+598") {
$mensaje = $mensaje . "Ingrese Teléfono
\n";
$error = true;
} // endif
// CHEQUEAR ERROR
if ($error) {
echo $mensaje;
} else {
// PROCESAR DATOS
echo "Tu Nombre es: $Nombre
\n";
echo "Tu Dirección es: $Direccion
\n";
echo "Tu Teléfono es: $Telefono
\n"; } // endif
?>


Archivo .html :

Ejemplo Validar Formulario lado SERVER

Nombre:

Dirección:

Teléfono:



No hay comentarios:

Publicar un comentario