Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['registerBtn']))
- {
- $captcha = $_POST['g-recaptcha-response'];
- $username = $_POST['username'];
- $password = $_POST['password'];
- $confirmpassword = $_POST['confirmPass'];
- $ipadd = $_SERVER['REMOTE_ADDR'];
- $date = date('l jS of F Y h:i:s A');
- if(!$captcha)
- {
- echo
- '
- <div class="alert alert-danger">
- <strong>Error:</strong> Please enter a captcha!
- </div>
- ';
- }
- else if($captcha)
- {
- $response = @file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=google_secret_key&response=".$captcha);
- if($response.success == false)
- {
- echo
- '
- <div class="alert alert-danger">
- <strong>Error:</strong> Incorrect captcha!
- </div>
- ';
- }
- else
- {
- $checkUsername = $odb->prepare("SELECT COUNT(*) FROM `users` WHERE `username` = :username");
- $checkUsername->execute(array(':username' => $username));
- $countUsername = $checkUsername -> fetchColumn(0);
- $checkEmail = $odb->prepare("SELECT COUNT(*) FROM `users` WHERE `email` = :email");
- $checkEmail->execute(array(':email' => $email));
- $countEmail = $checkEmail -> fetchColumn(0);
- if(!($countEmail == 0))
- {
- echo
- '
- <div class="alert alert-danger">
- <strong>Error:</strong> That e-mail is already in use!
- </div>
- ';
- }
- else if(!($countUsername == 0))
- {
- echo
- '
- <div class="alert alert-danger">
- <strong>Error:</strong> That username is already in use!
- </div>
- ';
- }
- else if(!(strcmp($password, $confirmpassword) == 0))
- {
- echo
- '
- <div class="alert alert-danger">
- <strong>Error:</strong> The passwords do not match!
- </div>
- ';
- }
- else
- {
- try
- {
- $insertUser = $odb -> prepare('INSERT INTO `users` (username,password,email,date_registered,ip,confirm_id,confirmed) VALUES(:username,:password, :email, :_date, :ip, :confirm_id, :confirmed)');
- $confirmid = $username;
- $confirmid .= $email;
- $confirmid = md5($confirmid);
- $insertUser -> execute(array(
- ':username' => $username,
- ':password' => password_hash($password, PASSWORD_BCRYPT),
- ':email' => $email,
- ':_date' => $date,
- ':ip' => $ipadd,
- ':confirm_id' => $confirmid,
- ':confirmed' => 0
- ));
- $_to = $email;
- $_subject = "PayEasy | Confirm your account";
- $_message = str_replace("%confirmid%", $confirmid, file_get_contents("email-templates/action.html"));
- $_headers = "MIME-Version: 1.0" . "rn";
- $_headers .= "Content-type:text/html;charset=UTF-8" . "rn";
- $_headers .= 'From: no-reply@payeasy.pw' . "rn";
- mail($_to,$_subject,$_message,$_headers);
- echo
- '
- <div class="alert alert-success">
- <strong>Success:</strong> Please check your e-mail for confirmation!
- </div>
- ';
- }
- catch (PDOException $e)
- {
- echo
- '
- <div class="alert alert-success">
- <strong>Error:</strong>'.$e->getMessage().'
- </div>
- ';
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement