Advertisement
Guest User

Untitled

a guest
Nov 28th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.63 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "balaboxc_javier";
  5. $password = "********";
  6.  
  7. // Create connection
  8. $conn = mysqli_connect($servername, $username, $password, 'balaboxc_viscaya_pruebas');
  9.    
  10.     $nombres = $_POST["nombres"];
  11.     $apellidos = $_POST["apellidos"];
  12.     // $fecha_nacimiento = $_POST["fecha_nacimiento"];
  13.     $correo = $_POST["correo"];
  14.     $contrasena = $_POST["contrasena"];
  15.     $localidad = $_POST["localidad"];
  16.     $authKey = md5(uniqid(rand(), true));
  17.  
  18.     $hash = password_hash("$contrasena", PASSWORD_DEFAULT);
  19.  
  20.  
  21.     $subject = "Confirma tu cuenta";
  22.  
  23.     $message = "
  24. <html>
  25. <head>
  26. <title>Confirma tu cuenta</title>
  27. </head>
  28. <body>
  29. <div style='margin-bottom: 20px;'>
  30.        <div style='background: #3b90e4; padding: 10px; border-radius:5px; text-align:center'>
  31.        
  32. <p style='font-size:25px;text-align:center; padding: 10px; color: #fff; font-family: Arial, Helvetica, sans-serif;'>¡Enhorabuena, te has registrado, solo falta que confirmes tu cuenta!</p>    
  33.    </div>
  34.    <p style='text-align:center; font-size: 17px; color: #949494; font-family: Arial, Helvetica, sans-serif;'>Tendrás muchas ventajas al estar registrado</p>
  35.    <div style='text-align:center; margin-top:20px'>
  36.    <video width='320' height='176' controls>
  37.        <source src='http://www.w3schools.com/html/mov_bbb.mp4' type='video/mp4'>
  38.        <source src='http://www.w3schools.com/html/mov_bbb.ogg' type='video/ogg'>
  39.          
  40.    </video>
  41. <a style='background: #ffa700; padding: 10px; border-radius: 7px; color: #fff; text-decoration: inherit;font-family: Arial, Helvetica, sans-serif;' target='blank' href='http://www.balabox.com/viscaya/welcomeViscaya.php?email=$correo&authKey=$authKey'>Haz click aquí para confirmar tu cuenta</a>
  42. </div>
  43. </div>
  44. </body>
  45. </html>
  46. ";
  47.  
  48. $headers = "MIME-Version: 1.0" . "\r\n";
  49. $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
  50.  
  51.  
  52. $headers .= 'From: <confirmar-noreply@balabox.com>' . "\r\n";
  53.  
  54. $mensaje = "";
  55.  
  56. $select = mysqli_query($conn, "SELECT `mail` FROM `usuarios` WHERE `mail` = '$correo'") or exit(mysqli_error());
  57. if(mysqli_num_rows($select)){
  58. echo "¡Parece que este correo ta está registrado!";
  59. $mensaje = "Reintentar";
  60. } else {
  61.     echo "¡Listo, se te ha enviado un correo de confirmación!";
  62.  
  63.     $mensaje = "Hecho";
  64.     $sql = "INSERT INTO usuarios (nombres, apellidos, fecha_nacimiento, localidad, mail, contrasena, authKey)
  65. VALUES ('$nombres', '$apellidos', '$fecha_nacimiento', '$localidad', '$correo', '$hash', '$authKey');";
  66.  
  67. if ($conn->multi_query($sql) === TRUE) {
  68.     mail($correo,$subject,$message,$headers);
  69. } else {
  70.    
  71. }
  72.  
  73. }
  74.  
  75.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement