/** * Inserts a user account field into the DB and returns the insert_id. * * @param object $emailAddress (username) * @param object $password (in clear text) * @param object $displayName * @return */ private static function dbTask_insertUser($emailAddress, $password, $displayName) { self::_init(); $passwordHash = phpPass::hashPassword($password); $stmt = self::$mysqli->prepare("INSERT INTO `users` SET `emailAddress`=?,`displayName`=?,`passwordHash`=?"); /* Can be used for debugging: if ( false===$stmt ) die('prepare() failed: ' . htmlspecialchars(self::$mysqli->error)); */ $stmt->bind_param('sss', $emailAddress, $displayName, $passwordHash); $stmt->execute(); $insertId = $stmt->insert_id; $stmt->close(); return $insertId; }
private static function init() { self::$passwordHash = new PasswordHash(8, false); }