Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['registerBtn']))
  3. {
  4.  
  5. $captcha = $_POST['g-recaptcha-response'];
  6. $username = $_POST['username'];
  7. $password = $_POST['password'];
  8. $confirmpassword = $_POST['confirmPass'];
  9. $ipadd = $_SERVER['REMOTE_ADDR'];
  10. $date = date('l jS of F Y h:i:s A');
  11.  
  12. if(!$captcha)
  13. {
  14. echo
  15. '
  16. <div class="alert alert-danger">
  17. <strong>Error:</strong> Please enter a captcha!
  18. </div>
  19. ';
  20. }
  21. else if($captcha)
  22. {
  23. $response = @file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=google_secret_key&response=".$captcha);
  24. if($response.success == false)
  25. {
  26. echo
  27. '
  28. <div class="alert alert-danger">
  29. <strong>Error:</strong> Incorrect captcha!
  30. </div>
  31. ';
  32. }
  33. else
  34. {
  35. $checkUsername = $odb->prepare("SELECT COUNT(*) FROM `users` WHERE `username` = :username");
  36.  
  37. $checkUsername->execute(array(':username' => $username));
  38.  
  39. $countUsername = $checkUsername -> fetchColumn(0);
  40.  
  41. $checkEmail = $odb->prepare("SELECT COUNT(*) FROM `users` WHERE `email` = :email");
  42.  
  43. $checkEmail->execute(array(':email' => $email));
  44.  
  45. $countEmail = $checkEmail -> fetchColumn(0);
  46.  
  47. if(!($countEmail == 0))
  48. {
  49. echo
  50. '
  51. <div class="alert alert-danger">
  52. <strong>Error:</strong> That e-mail is already in use!
  53. </div>
  54. ';
  55. }
  56. else if(!($countUsername == 0))
  57. {
  58. echo
  59. '
  60. <div class="alert alert-danger">
  61. <strong>Error:</strong> That username is already in use!
  62. </div>
  63. ';
  64. }
  65. else if(!(strcmp($password, $confirmpassword) == 0))
  66. {
  67. echo
  68. '
  69. <div class="alert alert-danger">
  70. <strong>Error:</strong> The passwords do not match!
  71. </div>
  72. ';
  73. }
  74. else
  75. {
  76. try
  77. {
  78. $insertUser = $odb -> prepare('INSERT INTO `users` (username,password,email,date_registered,ip,confirm_id,confirmed) VALUES(:username,:password, :email, :_date, :ip, :confirm_id, :confirmed)');
  79.  
  80. $confirmid = $username;
  81. $confirmid .= $email;
  82. $confirmid = md5($confirmid);
  83.  
  84. $insertUser -> execute(array(
  85.  
  86. ':username' => $username,
  87. ':password' => password_hash($password, PASSWORD_BCRYPT),
  88. ':email' => $email,
  89. ':_date' => $date,
  90. ':ip' => $ipadd,
  91. ':confirm_id' => $confirmid,
  92. ':confirmed' => 0
  93.  
  94. ));
  95.  
  96. $_to = $email;
  97. $_subject = "PayEasy | Confirm your account";
  98.  
  99. $_message = str_replace("%confirmid%", $confirmid, file_get_contents("email-templates/action.html"));
  100.  
  101. $_headers = "MIME-Version: 1.0" . "rn";
  102. $_headers .= "Content-type:text/html;charset=UTF-8" . "rn";
  103. $_headers .= 'From: no-reply@payeasy.pw' . "rn";
  104.  
  105. mail($_to,$_subject,$_message,$_headers);
  106.  
  107. echo
  108. '
  109. <div class="alert alert-success">
  110. <strong>Success:</strong> Please check your e-mail for confirmation!
  111. </div>
  112. ';
  113. }
  114. catch (PDOException $e)
  115. {
  116. echo
  117. '
  118. <div class="alert alert-success">
  119. <strong>Error:</strong>'.$e->getMessage().'
  120. </div>
  121. ';
  122. }
  123. }
  124. }
  125. }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement