Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'core/findConflict.php';
- $username = $_POST['username'];
- $password = $_POST['password'];
- $cpassword = $_POST['cpassword'];
- $email = $_POST['email'];
- $hash = password_hash($password, PASSWORD_DEFAULT);
- $query = dbConnect()->prepare("SELECT email, username FROM users WHERE username = :username OR email = :email");
- $query->bindParam(':username', $username);
- $query->bindParam(':email', $email);
- $query->execute();
- $conflictingItems = [];
- while ( $result = $query->fetch( PDO::FETCH_ASSOC ) ) {
- $conflictingItems[] = $result;
- }
- // for checking checkGoogleCaptcha() function!!
- require_once 'core/recaptchalib.php';
- if(isset($_POST['g-recaptcha-response']))
- $captcha = $_POST['g-recaptcha-response'];
- $response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6Levrg4TAAAAAFmjcgKW8kDakmXTiBhmiCnUMchD&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']), true);
- if ( count ($conflictingItems) == 1 ) {
- switch ( getConflict($conflictingItems, $username, $email) ) {
- case 1:
- // username conflict
- echo "<p class='error'>username taken</p>";
- break;
- case 2:
- // Email conflict
- echo "<p class='error'>email already in use</p>";
- break;
- case 3:
- // email & username conflict
- echo '<p class="error">username & email in use</p>';
- break;
- }
- } elseif ( count($conflictingItems) == 2 ) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement