Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2. // Let's include the defines.
  3. include('defines.php');
  4.  
  5. if ($pass == null || $pass == "" || $pass2 == null || $pass2 == "" || $username == null || $username == "" || $email == null || $email == "" || $age == null || $age == "")
  6. header('Location: register.html');
  7. if($pass != $pass2) // Are the passwords equal?
  8. header('Location: register.html'); // If not, redirect the user to the registration form.
  9. if(strlen($username) > 30) // Is the username's length greater then 30?
  10. header('Location: register.html'); // Is so, redirect the user to the registration form.
  11.  
  12. // Hash the password.
  13. $hash = hash('sha256', $pass);
  14.  
  15. //creates a 3 character sequence
  16. function createSalt()
  17. {
  18. $string = md5(uniqid(rand(), true));
  19. return substr($string, 0, 3);
  20. }
  21. $salt = createSalt();
  22. $hash = hash('sha256', $salt . $hash);
  23.  
  24. // Here comes the MySQL part of it.
  25. mysql_select_db($dbname, $conn);
  26.  
  27. //sanitize username
  28. $username = mysql_real_escape_string($username);
  29. $query = "INSERT INTO lusers ( username, password, salt )
  30. VALUES ( '$username' , '$hash' , '$salt' );";
  31. mysql_query($query);
  32. mysql_close();
  33. header('Location: login_form.php');
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement