prepare("SELECT id FROM users WHERE username = ?"); $stmt->execute([$username]); if ($stmt->fetch()) { $errors[] = 'Username is already taken.'; } else { $password_hash = password_hash($password, PASSWORD_DEFAULT); $stmt = $pdo->prepare("INSERT INTO users (username, password_hash) VALUES (?, ?)"); $stmt->execute([$username, $password_hash]); // Log the user in $_SESSION['user_id'] = $pdo->lastInsertId(); $_SESSION['username'] = $username; header('Location: index.php'); exit; } } catch (PDOException $e) { $errors[] = 'Database error. Please try again later.'; } } } require_once __DIR__ . '/includes/header.php'; ?>

Create an Account

Please enter a username.
Please enter a password.
Please confirm your password.

Already have an account? Login here.