Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2.  
  3. include('config.php');
  4. include('register.php');
  5.  
  6. //test to see if username is alphannumberic
  7. $test=$_POST[username];
  8.  
  9. if(!preg_match('/[^A-Za-z0-9]/ i' , $test)){
  10.    
  11.         //test for duplicate names
  12.         $query="SELECT * FROM users WHERE username ='$_POST[username]'";
  13.         $result=mysql_query(query);
  14.         $num=mysql_num_rows($result);
  15.        
  16.         if ($num == 0){
  17.            
  18.             //insert users into table
  19.             $sql="INSERT INTO users SET username = '$user', password = '$pass'";
  20.             $result=mysql_query($sql);
  21.            
  22.             //Shows "Thanks for registering" page
  23.             header("Location:thanksreg.html");
  24.            
  25.            
  26.             }else{
  27.             header("Location:nameinuse.html"); 
  28.             }
  29.    
  30.     }else{
  31.     header("Location:invalidname.html");
  32.     }
  33.  
  34.  
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement