prepare("SELECT id, password, role_id FROM users WHERE username = :username"); $stmt->bindParam(':username', $username); $stmt->execute(); $user = $stmt->fetch(PDO::FETCH_ASSOC); if ($user && password_verify($password, $user['password'])) { $_SESSION['user_id'] = $user['id']; $_SESSION['username'] = $username; $_SESSION['role_id'] = $user['role_id']; header("Location: index.php"); exit(); } else { $error_message = 'Invalid username or password.'; } } } // Fetch header content ob_start(); include 'index.php'; $page_content = ob_get_clean(); // Extract only the
and