Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/11/2009, 08:41
vili86
 
Fecha de Ingreso: septiembre-2009
Mensajes: 281
Antigüedad: 14 años, 7 meses
Puntos: 0
Exclamación Simple consulta ?

Amigos tengo dos campos en mi formulario que deben de ser unicos EL CI Y EL DNI bueno al insertar cualquiera de las dos opciones estas deden de ser unicas y si ubiera una igual votarle el mensaje que ya existe este numero bueno hice esto
Código php:
Ver original
  1. $ci = $_SESSION['ci'] =  intval($_POST['ci']);
  2. $registro_fbf = intval($_POST['registro_fbf']);
  3. $link = Conectarse();
  4.             $sqlQueryCat = mysql_query("SELECT * FROM clIentes where ((DNI='$DNI') and (ci = '$ci'))", $link)or die(mysql_error);
  5.             $rowCat = mysql_fetch_array($sqlQueryCat);
  6.  
  7. if ( (($registro_fbf != $rowCat['registro_fbf']) || ($ci != $rowCat['ci']))  ){
  8.  
  9.  // INSERTO EN LA BASE
  10.  
  11. }
  12.                                
  13.                                 else{
  14.                                   echo "<center><strong> El registro Generado ó el CI ya existe !!! lo sentimos vuelva a intentar de nuevo </strong></center>";
  15.                                 }

Casos:
1 Cuando inserto un DNI que es generado automaticamente y comprabado antes por ajax que ese numero no esta registro en la bd y sin tener el CI insertar correctamente
2.- PERO CUANDO GENERO UN DNI QUE NO ESTA REGISTRADO EN LA BD PERO INSERTO UN CI QUE YA EXISTE EN LA BD DEBERIA SALIRME EL MENSAJE QUE NO SE PUEDE INSERTAR PERO NO LO HACE ????