Archivo .php :
Proceso Validar Formulario lado SERVER
// CREAR MENSAJE PREDETERMINADO
$mensaje = "ATENCION!!!...
\n";
\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";
\n";
$error = true;
} // endif
if ($Direccion=="") {
$mensaje = $mensaje . "Ingrese Dirección
\n";
\n";
$error = true;
} // endif
if ($Telefono=="" || $Telefono=="+598") {
$mensaje = $mensaje . "Ingrese Teléfono
\n";
\n";
$error = true;
} // endif
// CHEQUEAR ERROR
if ($error) {
echo $mensaje;
} else {
// PROCESAR DATOS
echo "Tu Nombre es: $Nombre
\n";
\n";
echo "Tu Dirección es: $Direccion
\n";
\n";
echo "Tu Teléfono es: $Telefono
\n"; } // endif
\n"; } // endif
?>
Archivo .html :
Ejemplo Validar Formulario lado SERVER
Nombre:
Dirección:
Teléfono:
No hay comentarios:
Publicar un comentario