daily pastebin goal
5%
SHARE
TWEET

Untitled

a guest May 23rd, 2018 656 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PHP
  2.  
  3. <?php
  4.  
  5. require "db.php";
  6.  
  7. function reg($hfuser, $user, $email, $pass) {
  8.  
  9. $hfuser = $_POST['hfuser'];
  10. $user = $_POST['username'];
  11. $email = $_POST['email'];    
  12. $pass = md5($_POST['password']);
  13. $errors = array();
  14.  
  15. $qry = mysql_query("INSERT INTO `users`(`hfuser`, `user`, `email`, `pass`)
  16. VALUES('$hfuser', '$user', '$email', '$pass') ");
  17.  
  18. $result = mysql_query($qry);
  19.  
  20. mysql_close();
  21.  
  22. $check = mysql_query("SELECT `user` FROM `users` WHERE `user`=$user");
  23.  
  24. $user_ex = mysql_query("$check");
  25.  
  26.  
  27. if (!$user) {
  28.    
  29.     $errors[] = "Username is not defined!";
  30.  
  31. }
  32.  
  33. if (!$pass) {
  34.    
  35.     $errors[] = "Password is not defined!";
  36.  
  37. }
  38.  
  39. if (!$email) {
  40.    
  41.     $errors[] = "E-mail is not defined!";
  42.  
  43. }
  44.  
  45. if ($user) {
  46.    
  47.     if (!ctype_alnum($user)) {
  48.        
  49.         $errors[] = "Username can only contain numbers & letters!";
  50.  
  51.     }
  52.  
  53. }
  54.  
  55. $range = range(1,15);
  56.  
  57. if (!in_array(strlen($user), $range)) {
  58.    
  59.     $errors[] = "Username must be between one and fifteen characters!";
  60.  
  61. }
  62.  
  63. if($email){
  64.             $checkemail = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
  65.  
  66. }
  67.  
  68.             if(!@preg_match($checkemail, $email)){
  69.                 $errors[] = "E-mail is not valid, must be name@server.tld!";
  70.             }
  71.  
  72. if ($user_ex) {
  73.    
  74.     echo "I am sorry, but that username is not available.";
  75.     unset($user);
  76.  
  77. }
  78.  
  79. }
  80. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top