Advertisement
Guest User

Untitled

a guest
Jun 11th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. if( empty( $_POST['register'] ) === false ) {
  2.  
  3.     $errors = array();
  4.    
  5.     $username = clean( $_POST['username'] );
  6.     $password = encrypt( $_POST['password'] );
  7.    
  8.     if( !$_POST['username'] || !$_POST['password'] ) {
  9.  
  10.         $errors[] = 'You left a field blank';
  11.  
  12.     }
  13.    
  14.     if( strlen($username) > 30 ) {
  15.  
  16.         $errors[] = 'Your username cannot exceed 30 characters.';
  17.  
  18.     }
  19.    
  20.     $query = mysql_query( "SELECT username FROM users WHERE username = '$username'" );
  21.     $count = mysql_num_rows( $query );
  22.    
  23.     if($count > 0 ) {
  24.  
  25.         $errors[] = 'That username is already taken. Please choose another one.';
  26.  
  27.     }
  28.    
  29.     if( $errors ) {
  30.         foreach( $errors as $disperrors ) {
  31.  
  32.             echo $disperrors.'<br />';
  33.  
  34.         }
  35.  
  36.         echo 'Click <a href="register.php">here</a> to go back.';
  37.         die();
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement