Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (sizeof($errors) === 0) {
- if (isset($_POST["register"])) {
- $sql = $db->prepare(
- "SELECT 1
- FROM users
- WHERE username = :username");
- $sql->bindParam(":username", $_POST["username"]);
- $sql->execute();
- $data = $sql->fetch();
- $usernameFree = isset($data);
- if (!$usernameFree) {
- die('Username taken');
- } else {
- $sql = $db->prepare(
- "INSERT INTO users (username, password)
- VALUES (:username, :password)");
- $sql->bindParam(":username", $_POST["username"]);
- $password = passwordHash($_POST["password"]);
- $sql->bindParam(":password", $password);
- $sql->execute();
- $_SESSION["logged"] = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement