Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once("config.php");
- if(isset($_POST['register'])) {
- $username = htmlentities($_POST['username'], ENT_QUOTES);
- $usernamel = strtolower($username);
- $password = htmlentities($_POST['password'], ENT_QUOTES);
- $password_hashed = password_hash($password, PASSWORD_BCRYPT);
- $email = htmlentities($_POST['email'], ENT_QUOTES);
- $ip = $_SERVER['REMOTE_ADDR'];
- $time = date("Y-m-d");
- $stmt = $db->prepare("SELECT * FROM users WHERE username = :username");
- $stmt->execute(array(':username' => $username));
- $row = $stmt->fetch();
- if($row['username'] == $username){
- die(header("Location: error.php"));
- exit;
- }
- if($username == ""){
- die(header("Location: error.php"));
- exit;
- }
- if($password == ""){
- die(header("Location: error.php"));
- exit;
- }
- if($email == ""){
- die(header("Location: error.php"));
- exit;
- }
- if($email == ""){
- die(header("Location: error.php"));
- exit;
- }
- if (strlen($username) < 10 && preg_match('/[^a-z0-9]+/i', $username) < 1) {
- if (strlen($password) > 8) {
- $stmt = $db->prepare("INSERT INTO users (username, usernamel, password, email, ip, date) VALUES (:username, :usernamel, :password, :email, :ip, :date)");
- $stmt->execute(array(':username' => $username, ':usernamel' => $usernamel, ':password' => $password_hashed, ':email' => $email, ':ip' => $ip, ':date' => $time));
- die(header("Location: index.php"));
- exit;
- } else {
- echo "Password needs to be higher than 8.";
- exit;
- }
- } else {
- echo "Username needs to be lower than 10 and cant contains specialchars (!@^*& etc)";
- exit;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement