← Foro de PHP

Validar datos en php

Hilo en el foro de PHP · 20 de Octubre del 2003 · 1 respuestas
mcabrejo20 de Octubre del 2003
Pregunta
Hola amigos, quisiera saber si alguien puede ayudarme en lo sgte. Tengo un formulario php, he creado una funcion para validar pero no lo hace pueden guiarme porfavor
<?
function check_form(){
global $con_nombre, $error;
$print_again = false;
if($con_nombre == “”) {
$error=”Ingrese nombre por favor...”;
}
else {
print (“ <h3> Gracias por usar el formulario php </h3>”);
}
}//fin de la funcion check_form()
?>
</head>
<body>
<?
if ($btnenviar==”Enviar”){check_form();exit();}
?>

<form name=”frmdatos” action=”contactenos.php” method=”post”>
<table >
<tr>
<td >Nombre </td>
<td > <input name=”con_nombre” value=”” type=”text” ></td>
</tr>
<input name="btnenviar" type="submit" id="btnenviar" value="Enviar">
</table>
</form>

Respuestas 1

miglesias20 de Octubre del 2003
Te he corregido algunas cosillas.


<?
function check_form(){
$print_again = false;
if($_POST['con_nombre'] == "") {
print "Ingrese nombre por favor...";
}
else {
print (" <h3> Gracias por usar el formulario php </h3>");
}
}//fin de la funcion check_form()
?>
</head>
<body>
<?
if ($_POST['btnenviar']=="Enviar"){check_form();exit();}
?>

<form name="frmdatos" action="prueba.php" method=post>
<table >
<tr>
<td >Nombre </td>
<td > <input name="con_nombre" value="" type=?text? ></td>
</tr>
<input name="btnenviar" type="submit" id="btnenviar" value="Enviar">
</table>
</form>
¿Buscas más hilos como este? Mira el foro de PHP o usa el buscador.