Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. <?php
  2.  
  3. include("connection.php");
  4. if(isset($_POST['submit']))
  5. {
  6. if($_POST['nombre'] == '' or $_POST['apellido'] == '' or $_POST['email'] == '' or $_POST['usuario'] == '' or $_POST['pass'] == '')
  7. {
  8. echo "Debe llenar todo los datos por favor.";
  9. }else{
  10. $sql = 'SELECT * FROM monitores';
  11. $rec = mysqli_query($conexion,$sql);
  12. $verificar = 0;
  13.  
  14. while($resultado = mysqli_fetch_object($rec))
  15. {
  16. if($resultado->usuario == $_POST['usuario'])
  17. {
  18. $verificar = 1;
  19. }
  20. }
  21. if($verificar == 0)
  22. {
  23. $nom = $_POST['nombre'];
  24. $apel = $_POST['apellido'];
  25. $mail = $_POST['email'];
  26. $usr = $_POST['usuario'];
  27. $pass = $_POST['pass'];
  28.  
  29. $conexion->query("INSERT INTO monitores (nombre,apellido,email,usuario,contrasena) VALUES ('$nom','$apel','$mail','$usr','$pass')");
  30. mysqli_query($conexion,$sql);
  31.  
  32.  
  33. echo ' <script language="javascript">alert("Usuario registrado con éxito");</script> ';
  34.  
  35. }
  36. }
  37. }
  38.  
  39.  
  40.  
  41. ?>
  42.  
  43. <?php
  44. $host="localhost";
  45. $hostuser="root";
  46. $hostpw="";
  47. $hostdb="fdj";
  48.  
  49. $conexion = mysqli_connect($host, $hostuser, $hostpw);
  50.  
  51. if (!$conexion) {
  52. die('No se ha podido conectar a la base de datos');
  53. }
  54.  
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement