SHARE
TWEET

Untitled

a guest May 22nd, 2017 173 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include "../config.php";
  3. require "../libraries/PHPMailer/PHPMailerAutoload.php";
  4.  
  5. $mail = new phpmailer;
  6. $mail->isSMTP();
  7. $mail->Host = "smtp.gmail.com";
  8. $mail->SMTPAuth = true;
  9. $mail->Username = "gmail";
  10. $mail->Password = "password";
  11. $mail->SMTPSecure = true;
  12. $mail->Port = "465";
  13. $mail->setFrom('gmail', 'name');
  14. $mail->isHTML(true);
  15.  
  16.  
  17. if (isset($_POST['register']))
  18. {
  19. $sid = mysqli_real_escape_string($con, $_POST['sid']);
  20. $email = mysqli_real_escape_string($con, $_POST['email']);
  21. $pw = hash("sha256", mysqli_real_escape_string($con, $_POST['pw']));
  22. $fn = mysqli_real_escape_string($con, $_POST['fn']);
  23. $ln = mysqli_real_escape_string($con, $_POST['ln']);
  24. $mob = mysqli_real_escape_string($con, $_POST['mob']);
  25.  
  26. $sql_validate = "SELECT schoolID FROM users WHERE schoolID=$sid";
  27. $result_validate = $con->query($sql_validate) or die(mysqli_error($con));
  28.  
  29. if (mysqli_num_rows($result_validate) == 0)
  30. {
  31. $sql_register = "INSERT INTO users VALUES ('', 1, $sid, '$email', '$pw', '$fn', '$ln', '$mob', 'Pending', NOW())";
  32. $con->query($sql_register) or die(mysqli_error($con));
  33. $url = "http://localhost:8080/exercises/02/account/confirm.php?e=$email&pw=$pw";
  34. $mail->addAddress($email, $fn . " " . $ln);
  35. $mail->Subject = "Account Confirmation";
  36. $mail->Body = "
  37. Welcome, $fn $ln ($sid)!<br /><br />
  38. You have successfully registered your account.
  39. Your email address is: $email <br /><br />
  40. Click the confirmation link below:<br />
  41. <a href='$url' target='_blank'>$url</a>
  42. <br /><br />
  43. Thank you!<br/>
  44. - Name
  45. ";
  46.  
  47. if(!$mail->send())
  48. {
  49. echo 'Message could not be sent.';
  50. echo 'Mailer Error: ' . $mail->ErrorInfo;
  51. }
  52. else
  53. echo 'Message has been sent';
  54.  
  55. header('location: login.php');
  56. }
  57. }
  58. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top