Ver Mensaje Individual
  #11 (permalink)  
Antiguo 20/08/2012, 21:28
Avatar de Nemutagk
Nemutagk
Colaborador
 
Fecha de Ingreso: marzo-2004
Ubicación: México
Mensajes: 2.633
Antigüedad: 20 años, 1 mes
Puntos: 406
Respuesta: Duplicación de registros

Código PHP:
Ver original
  1. <?php
  2. include ("Conexion.php");
  3.  
  4. if(isset($_POST['nombre']) && !empty ($_POST['nombre']) &&
  5. isset($_POST['materia']) && !empty ($_POST['materia']) &&
  6. isset($_POST['grupo']) && !empty ($_POST['grupo']) &&
  7. isset($_POST['matricula']) && !empty ($_POST['matricula']) &&
  8. isset($_POST['pw']) && !empty ($_POST['pw']) &&
  9. isset($_POST['pw2']) && !empty ($_POST['pw2']) &&
  10. isset($_POST['email']) && !empty ($_POST['email']) &&  
  11. $_POST['pw'] == $_POST['pw2'])
  12.  
  13. {
  14.      
  15.     $con=mysql_connect($host,$user,$pw)
  16.     or die ("problemas al conectar el servidor");
  17.      
  18.     mysql_select_db($db,$con)
  19.     or die ("problemas al conectar la base de datos");
  20.      
  21. $query = mysql_query('SELECT COUNT(*) FROM registro WHERE matricula = "'.$_POST['matricula'].'"',$con) or die(mysql_error());
  22.  
  23. if (mysql_result($query,0) == 0) {
  24.      mysql_query ("INSERT INTO registro (NOMBRE,MATERIA,GRUPO,MATRICULA,PW,EMAIL)
  25. VALUES ('$_POST[nombre]','$_POST[materia]','$_POST[grupo]','$_POST[matricula]','$_POST[pw]','$_POST[email]')",$con);
  26.      echo 'No existe la matricula '.$_POST['matricula'];
  27. }else {
  28.      echo 'La matricula '.$_POST['matricula'].' ya existe en la tabla';
  29. }
  30.  
  31.     header("Location: Ingresar.php");    
  32.      
  33. }else{  
  34.      
  35.     echo "Verifica si los campos estan llenos o si los Passworsd coinciden";
  36.     }
__________________
Listo?, tendría que tener 60 puntos menos de IQ para considerarme listo!!!
-- Sheldon Cooper
http://twitter.com/nemutagk
PD: No contestaré temas vía mensaje personal =)