Validar datos en php
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>
<?
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>
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>
<?
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>
