Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Let's include the defines.
- include('defines.php');
- if ($pass == null || $pass == "" || $pass2 == null || $pass2 == "" || $username == null || $username == "" || $email == null || $email == "" || $age == null || $age == "")
- header('Location: register.html');
- if($pass != $pass2) // Are the passwords equal?
- header('Location: register.html'); // If not, redirect the user to the registration form.
- if(strlen($username) > 30) // Is the username's length greater then 30?
- header('Location: register.html'); // Is so, redirect the user to the registration form.
- // Hash the password.
- $hash = hash('sha256', $pass);
- //creates a 3 character sequence
- function createSalt()
- {
- $string = md5(uniqid(rand(), true));
- return substr($string, 0, 3);
- }
- $salt = createSalt();
- $hash = hash('sha256', $salt . $hash);
- // Here comes the MySQL part of it.
- mysql_select_db($dbname, $conn);
- //sanitize username
- $username = mysql_real_escape_string($username);
- $query = "INSERT INTO lusers ( username, password, salt )
- VALUES ( '$username' , '$hash' , '$salt' );";
- mysql_query($query);
- mysql_close();
- header('Location: login_form.php');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement