Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php
  2. include 'connection.php';
  3.  
  4. $username = $_POST['username'];
  5. $password = $_POST['password'];
  6. $passwordconfirm = $_POST['password1'];
  7. $email = $_POST['email'];
  8. $emailconfirm = $_POST['email1'];
  9.  
  10. if (ctype_alnum($username))
  11. {
  12.     $query = "SELECT username FROM users WHERE username = '$username'";
  13.     $checkname = mysql_query($query);
  14.     $rows = mysql_num_rows($checkname);
  15.     // check username
  16.     if ($rows == 0)
  17.     {
  18.         $queryemail="SELECT email FROM users WHERE email='$email'";
  19.  
  20.         $emailcheck = mysql_query($queryemail);
  21.         $rows1 = mysql_num_rows($emailcheck);
  22.         // check email
  23.         if ($rows1 == 0)
  24.         {
  25.             // Check to see if email and confirm email and password and confirm password match
  26.             if($email == $emailconfirm && $password == $passwordconfirm)
  27.             {  
  28.                 $query1 ="INSERT INTO users (username, password, email) VALUES('$username', '$password', '$email')";
  29.                 $insert = mysql_query($query1);
  30.             }  
  31.             else{
  32.                 echo "Your email and confirm email and password and confirm password has to match!";
  33.             }
  34.         }
  35.         else
  36.         {
  37.             echo "That email is already in use";
  38.         }
  39.     }
  40.     else{
  41.         echo "That username is already in use.";
  42.     }
  43. }
  44. else
  45. {  
  46.     echo "Your name can only be letters and numbers";
  47. }
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement