execute_query("SELECT username FROM $table WHERE username = ?", array($username)); $query = "INSERT INTO $table SET `username` = ?, `password` = ?, `email` = ?"; if ($found && $found->fetch_assoc()) { $exists = TRUE; } else if ($result = $db->execute_query($query, array($username, $password, $email))) { // If the password column cut the hash short, the editor could never log in if (password_hash_is_stored($username, $password)) { $added = TRUE; } else { remove_editor($username); $hash_failed = TRUE; } $is_admin = TRUE; } open_db('close'); } /* * The problems with a new username and password, as messages; an empty * list means that both are fine. The persistent login cookie holds * "username|key", so a username cannot contain "|". */ function new_editor_problems($username, $password) { $problems = array(); if (!is_string($username) || trim($username) === '') $problems[] = 'Please enter a username.'; else if ($username !== trim($username) || strlen($username) > 64 || preg_match('/[|\p{Cc}]/u', $username) !== 0) $problems[] = 'A username has at most 64 characters, with no spaces at the ends and no "|".'; if (!is_string($password) || mb_strlen($password, 'UTF-8') < 12) $problems[] = 'A password needs at least 12 characters.'; else if (strlen($password) > 1024) $problems[] = 'A password has at most 1024 characters.'; else if (is_string($username) && strcasecmp($password, $username) === 0) $problems[] = 'The password cannot be the username.'; return $problems; } ?> x.x.x [add editor]

add editor

Added editor

Your session has expired. Please try again.

An editor with that username already exists.

The editor was not added: the editors.password column is too short for the password hash. Widen it to VARCHAR(255).