![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
27/10/2011, 00:35
|
![Avatar de animerika1](http://static.forosdelweb.com/customavatars/avatar439626_1.gif) | | | Fecha de Ingreso: octubre-2011
Mensajes: 27
Antigüedad: 13 años, 3 meses Puntos: 3 | |
Respuesta: como evitar registro si el email existe Prueba con este.
$Cuenta = Seguridad($_POST["Cuenta"]);
$Nombre = Seguridad($_POST["Nombre"]);
$Apellidos = Seguridad($_POST["Apellidos"]);
$Email = Seguridad($_POST["Email"]);
if(!empty($_POST['Cuenta']) || !empty($_POST['Nombres']) || !empty($_POST['Apellidos']) || !empty($_POST['Email']))
{
/seleccionas la tabla donde quieres hacer la consulta:
mysql_select_db("usuarios", $conectar);
$busqueda= mysql_query("SELECT Email FROM usuarios WHERE Email='".$Email."'");
Haz la prueba con 2 tipos para ver cual te funciona, este :
if(mysql_num_rows($busqueda)>0) {
o este:
if($busqueda['Email'] == $_POST['Email']){
echo "email existe";
}
else {
$sql = "INSERT INTO usuarios (Cuenta,
Nombre,
Apellidos,
Email) VALUES ('".$Cuenta."',
'".$Nombre."',
'".$Apellidos."',
'".$Email."')";
mysql_query($sql,$conectar) or die(mysql_error());
$msg = "</td>
</tr>
</table>
<table class=\"cart_last_product std\">
<tr>
<th colspan=\"2\">Cuenta Registrada Correctamente.</th>
</tr>
</table>";
}
}
else {
$msg = "</td>
</tr>
</table>
<table class=\"cart_last_product std\">
<tr>
<th colspan=\"2\">Aviso: Rellene todo el formulario.</th>
</tr>
</table>";
}
} |