Ver Mensaje Individual
  #8 (permalink)  
Antiguo 27/10/2011, 00:17
andrea7755
 
Fecha de Ingreso: junio-2011
Mensajes: 76
Antigüedad: 12 años, 10 meses
Puntos: 0
Respuesta: como evitar registro si el email existe

aqui te envio es formulario unico como lo tengo
normalmente

Código PHP:
Ver original
  1. <?php
  2. @include("Includes/Configurar.php");
  3. @include("Includes/Funciones.php");
  4. @include("Includes/Conexion.php");
  5. $msg = "";
  6. if($_POST['agregar'])
  7. {
  8.  
  9.     if(!empty($_POST['Cuenta']) || !empty($_POST['Nombres']) || !empty($_POST['Apellidos']) || !empty($_POST['Email']))
  10.     {
  11.  
  12. $Cuenta = Seguridad($_POST["Cuenta"]);
  13. $Nombre = Seguridad($_POST["Nombre"]);
  14. $Apellidos = Seguridad($_POST["Apellidos"]);
  15. $Email = Seguridad($_POST["Email"]);
  16.  
  17. $sql = "INSERT INTO usuarios (Cuenta,
  18. Nombre,
  19. Apellidos,
  20. Email) VALUES ('".$Cuenta."',
  21. '".$Nombre."',
  22. '".$Apellidos."',
  23. '".$Email."')";
  24.         mysql_query($sql,$conectar) or die(mysql_error());
  25.         $msg = "</td>
  26. </tr>
  27. </table>
  28. <table class=\"cart_last_product std\">
  29. <tr>
  30. <th colspan=\"2\">Cuenta Registrada Correctamente.</th>
  31. </tr>
  32. </table>";
  33.     } else {
  34.         $msg = "</td>
  35. </tr>
  36. </table>
  37. <table class=\"cart_last_product std\">
  38. <tr>
  39. <th colspan=\"2\">Aviso: Rellene todo el formulario.</th>
  40. </tr>
  41. </table>";
  42.     }
  43. }
  44. if($_SESSION['Acceso'])
  45. {
  46.      $usuario = mysql_fetch_array(Query("SELECT * FROM `usuarios`  WHERE  Email='".$_SESSION['Email']."'"));
  47.      $privilegios = $usuario["privilegios"];
  48.  
  49.    
  50. }else
  51. {
  52.    
  53.    Redireccionar("loginpanel.html?nocache=".base64_encode(base64_encode(bin2hex(Seguridad($_SERVER['REQUEST_URI']))))."&tiempo=".time());
  54. }
  55. if($privilegios == "admin"){
  56. ?>
  57.  
  58. <?=$msg;?>
  59. <form name="rg" action="" method="post" enctype="multipart/form-data" class="std identity">
  60. <fieldset>
  61. <p class="required text">
  62. <label for="firstcuenta">Direccion de Cuenta</label>
  63. <input type="text" id="Cuenta" name="Cuenta" /> <sup>*</sup>
  64. </p>
  65.  
  66. <p class="required text">
  67. <label for="firstnombre">Nombres</label>
  68. <input type="text" id="Nombre" name="Nombre" /> <sup>*</sup>
  69. </p>
  70.  
  71. <p class="required text">
  72. <label for="firstapellido">Apellidos</label>
  73. <input type="text" id="Apellidos" name="Apellidos" /> <sup>*</sup>
  74. </p>
  75.  
  76. <p class="required text">
  77. <label for="firstemail">Correo Electronico</label>
  78. <input type="text" id="Email" name="Email" /> <sup>*</sup>
  79. </p>
  80. <p class="required required_desc"><sup>*</sup>Todos los Campos son Obligatorios</p>
  81.             <p class="submit">
  82.                 <input type="submit" class="button" name="agregar" value="Guardar" />
  83.             </p>
  84.         </fieldset>
  85.     </form>
  86. <?php }else
  87. {
  88. Redireccionar("home.html?nocache=".base64_encode(base64_encode(bin2hex(Seguridad($_SERVER['REQUEST_URI']))))."&tiempo=".time());
  89. }?>

y esta es la forma como me dices que lo realize:

Código PHP:
Ver original
  1. <?php
  2. @include("Includes/Configurar.php");
  3. @include("Includes/Funciones.php");
  4. @include("Includes/Conexion.php");
  5. $msg = "";
  6. if($_POST['agregar'])
  7. {
  8.  
  9. if(!empty($_POST['Cuenta']) || !empty($_POST['Nombres']) || !empty($_POST['Apellidos']) || !empty($_POST['Email']))
  10. {
  11.  
  12. $busqueda= mysql_query("SELECT Email FROM usuarios WHERE Email='".$Email."'");
  13.  
  14. if(mysql_num_rows($busqueda)>0) {
  15. echo "email existe";
  16.  
  17. }
  18.  
  19. else {
  20.  
  21. $Cuenta = Seguridad($_POST["Cuenta"]);
  22. $Nombre = Seguridad($_POST["Nombre"]);
  23. $Apellidos = Seguridad($_POST["Apellidos"]);
  24. $Email = Seguridad($_POST["Email"]);
  25.  
  26. $sql = "INSERT INTO usuarios (Cuenta,
  27. Nombre,
  28. Apellidos,
  29. Email) VALUES ('".$Cuenta."',
  30. '".$Nombre."',
  31. '".$Apellidos."',
  32. '".$Email."')";
  33. mysql_query($sql,$conectar) or die(mysql_error());
  34. $msg = "</td>
  35. </tr>
  36. </table>
  37. <table class=\"cart_last_product std\">
  38. <tr>
  39. <th colspan=\"2\">Cuenta Registrada Correctamente.</th>
  40. </tr>
  41. </table>";
  42.  
  43. }
  44. }
  45.  
  46. else {
  47. $msg = "</td>
  48. </tr>
  49. </table>
  50. <table class=\"cart_last_product std\">
  51. <tr>
  52. <th colspan=\"2\">Aviso: Rellene todo el formulario.</th>
  53. </tr>
  54. </table>";
  55. }
  56. }
  57. if($_SESSION['Acceso'])
  58. {
  59.      $usuario = mysql_fetch_array(Query("SELECT * FROM `usuarios`  WHERE  Email='".$_SESSION['Email']."'"));
  60.      $privilegios = $usuario["privilegios"];
  61.  
  62.    
  63. }else
  64. {
  65.    
  66.    Redireccionar("loginpanel.html?nocache=".base64_encode(base64_encode(bin2hex(Seguridad($_SERVER['REQUEST_URI']))))."&tiempo=".time());
  67. }
  68. if($privilegios == "admin"){
  69. ?>
  70. <?=$msg;?>
  71. <form name="rg" action="" method="post" enctype="multipart/form-data" class="std identity">
  72. <fieldset>
  73. <p class="required text">
  74. <label for="firstcuenta">Direccion de Cuenta</label>
  75. <input type="text" id="Cuenta" name="Cuenta" /> <sup>*</sup>
  76. </p>
  77.  
  78. <p class="required text">
  79. <label for="firstnombre">Nombres</label>
  80. <input type="text" id="Nombre" name="Nombre" /> <sup>*</sup>
  81. </p>
  82.  
  83. <p class="required text">
  84. <label for="firstapellido">Apellidos</label>
  85. <input type="text" id="Apellidos" name="Apellidos" /> <sup>*</sup>
  86. </p>
  87.  
  88. <p class="required text">
  89. <label for="firstemail">Correo Electronico</label>
  90. <input type="text" id="Email" name="Email" /> <sup>*</sup>
  91. </p>
  92. <p class="required required_desc"><sup>*</sup>Todos los Campos son Obligatorios</p>
  93.             <p class="submit">
  94.                 <input type="submit" class="button" name="agregar" value="Guardar" />
  95.             </p>
  96.         </fieldset>
  97.     </form>
  98. <?php }else
  99. {
  100. Redireccionar("home.html?nocache=".base64_encode(base64_encode(bin2hex(Seguridad($_SERVER['REQUEST_URI']))))."&tiempo=".time());
  101. }?>

pero pareciera que no hace nada.. y registra siempre todo igual