Advertisement
Guest User

Untitled

a guest
Nov 24th, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. <?php
  2.  
  3. $msg = "";
  4. use PHPMailer\PHPMailer\PHPMailer;
  5.  
  6.  
  7. include_once 'PHPMailer/Exception.php';
  8. include_once 'PHPMAiler/SMTP.php';
  9.  
  10. if (isset($_POST['submit'])) {
  11. $con = new mysqli('localhost', 'root', 'root', 'research_phpemailconfirmation');
  12.  
  13. $name = $con->real_escape_string($_POST['name']);
  14. $email = $con->real_escape_string($_POST['email']);
  15. $password = $con->real_escape_string($_POST['password']);
  16. $cPassword = $con->real_escape_string($_POST['cPassword']);
  17.  
  18. if ($name == "" || $email == "" || $password != $cPassword)
  19. $msg = "Please check your inputs!";
  20. else {
  21. $sql = $con->query("SELECT id FROM users WHERE email='$email'");
  22. if ($sql->num_rows > 100 ) {
  23. $msg = "Email already exists in the database!";
  24. }
  25. else {
  26. $msg = "TEST";
  27. $html = "<script>console.log('TEST');</script>";
  28. echo($html);
  29.  
  30. $token = 'qwertzuiopasdfghjklyxcvbnmQWERTZUIOPASDFGHJKLYXCVBNM0123456789!$/()*';
  31. $token = str_shuffle($token);
  32. $token = substr($token, 0, 10);
  33.  
  34. $hashedPassword = password_hash($password, PASSWORD_BCRYPT);
  35.  
  36. $con->query("INSERT INTO users (name,email,password,isEmailConfirmed,token)
  37. VALUES ('$name', '$email', '$hashedPassword', '0', '$token');
  38. ");
  39.  
  40. include_once "PHPMailer/PHPMailer.php";
  41.  
  42. $mail = new PHPMailer();
  43. $mail->IsSMTP();
  44. $mail->SMTPAuth = true;
  45. $mail->SMTPSecure = 'ssl';
  46. $mail->Host = "smtp.gmail.com";
  47. $mail->Port = 465;
  48. $mail->Username = "ADRESA@gmail.com";
  49. $mail->Password = "PAROLA";
  50.  
  51. $mail->setFrom('hello@codingpassiveincome.com', 'Test');
  52. $mail->addAddress($email, $name);
  53. $mail->Subject = "Please verify email!";
  54. $mail->isHTML(true);
  55. $mail->Body = "
  56.  
  57. Please click on the link below:<br><br>
  58.  
  59. <a href='http://codingpassiveincome.com/PHPEmailConfirmation/confirm.php?email=$email&token=$token'>Click Here</a>
  60. ";
  61.  
  62. if(!$mail->Send()) {
  63. $msg = "Something wrong happened! Please try again!";
  64. } else {
  65. $msg = "You have been registered! Please verify your email!";
  66. }
  67.  
  68.  
  69. }
  70. }
  71. }
  72. ?>
  73. <!doctype html>
  74. <html lang="en">
  75. <head>
  76. <meta charset="UTF-8">
  77. <meta name="viewport"
  78. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  79. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  80. <title>Register</title>
  81. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
  82. </head>
  83. <body>
  84. <div class="container" style="margin-top: 100px;">
  85. <div class="row justify-content-center">
  86. <div class="col-md-6 col-md-offset-3" align="center">
  87.  
  88. <img src="images/logo.png"><br><br>
  89.  
  90. <?php if ($msg != "") echo $msg . "<br><br>" ?>
  91.  
  92. <form method="post" action="reg.php">
  93. <input class="form-control" name="name" placeholder="Name..."><br>
  94. <input class="form-control" name="email" type="email" placeholder="Email..."><br>
  95. <input class="form-control" name="password" type="password" placeholder="Password..."><br>
  96. <input class="form-control" name="cPassword" type="password" placeholder="Confirm Password..."><br>
  97. <input class="btn btn-primary" type="submit" name="submit" value="Register">
  98. </form>
  99.  
  100. </div>
  101. </div>
  102. </div>
  103. </body>
  104. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement