Guest User

Untitled

a guest
Oct 18th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. <?php
  2.     include('configuration.php');
  3.     $user = strip_tags($_POST['username']);
  4.     $pw = strip_tags($_POST['pw']);
  5.     $pw2 = strip_tags($_POST['pw2']);
  6.     $email = strip_tags($_POST['email']);
  7.    
  8.     if($user && $pw && $pw2 && $email) {
  9.         if(strlen($user) > 20) {
  10.             echo '<script>alert("Username is too long.")</script>';
  11.         }elseif(strlen($user) < 4) {
  12.             echo '<script>alert("Username is too short.")</script>';
  13.         }elseif(strlen($pw) > 40) {
  14.             echo '<script>alert("Password is too long.")</script>';
  15.         }elseif(strlen($email) < 3) {
  16.             echo '<script>alert("Email is too short.")</script>';
  17.         }elseif($pw !== $pw2) {
  18.             echo '<script>alert("Passwords do not match.")</script>';
  19.         }else{
  20.             $getusernames = "SELECT * FROM `account` WHERE `username`='$user'";
  21.             $num_rows = mysql_num_rows($getusernames);
  22.             if ($num_rows = 0) {
  23.                 mysql_select_db("$realmdb", $connect);
  24.                 $pw_hash = sha1(strtoupper($user).':'.strtoupper($pw));
  25.                 $register_sql = mysql_query ("INSERT INTO account (username, sha_pass_hash, email, expansion) values ('$user', '$pw_hash', '$email', '1')");                
  26.                 echo '<script>alert("Account is successfully created!")</script>';
  27.             }else{
  28.                 echo '<script>alert("User already exists. Please try again!")</script>';
  29.             }
  30.         }
  31.     }else
  32.     ?>
Add Comment
Please, Sign In to add comment