Advertisement
Guest User

asdasdasd

a guest
Dec 1st, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. require 'core/findConflict.php';
  2.         $username = $_POST['username'];
  3.         $password = $_POST['password'];
  4.         $cpassword = $_POST['cpassword'];
  5.         $email = $_POST['email'];
  6.         $hash = password_hash($password, PASSWORD_DEFAULT);
  7.         $query = dbConnect()->prepare("SELECT email, username FROM users WHERE username = :username OR email = :email");
  8.         $query->bindParam(':username', $username);
  9.         $query->bindParam(':email', $email);
  10.         $query->execute();
  11.         $conflictingItems = [];
  12.         while ( $result = $query->fetch( PDO::FETCH_ASSOC ) ) {
  13.             $conflictingItems[] = $result;
  14.         }
  15.         // for checking checkGoogleCaptcha() function!!
  16.         require_once 'core/recaptchalib.php';
  17.         if(isset($_POST['g-recaptcha-response']))
  18.         $captcha = $_POST['g-recaptcha-response'];
  19.         $response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6Levrg4TAAAAAFmjcgKW8kDakmXTiBhmiCnUMchD&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']), true);
  20.  
  21.         if ( count ($conflictingItems) == 1 ) {
  22.           switch ( getConflict($conflictingItems, $username, $email) ) {
  23.               case 1:
  24.               // username conflict
  25.               echo "<p class='error'>username taken</p>";
  26.               break;
  27.               case 2:
  28.               // Email conflict
  29.               echo "<p class='error'>email already in use</p>";
  30.               break;
  31.               case 3:
  32.               // email & username conflict
  33.               echo '<p class="error">username & email in use</p>';
  34.               break;
  35.           }
  36.         } elseif ( count($conflictingItems) == 2 ) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement