// Adjusting userLogin function to set initial game_progress to 'entrance' function userLoginUpdated($username) { $db = getDB(); $stmt = $db->prepare('SELECT id, game_progress, preferences FROM users WHERE username = :username'); $stmt->bindParam(':username', $username, PDO::PARAM_STR); $stmt->execute(); $user = $stmt->fetch(PDO::FETCH_ASSOC); if ($user) { return ['id' => $user['id'], 'game_progress' => $user['game_progress'], 'preferences' => $user['preferences']]; } else { // User not found, try to register $stmt = $db->prepare('INSERT INTO users (username, game_progress, preferences) VALUES (:username, "entrance", "")'); $stmt->bindParam(':username', $username, PDO::PARAM_STR); $stmt->execute(); $userId = $db->lastInsertId(); return ['id' => $userId, 'game_progress' => 'entrance', 'preferences' => '']; } }
Start your adventure by logging in or registering!