prepare("UPDATE site_config SET active_style = :active_style WHERE id = 1"); $stmt->execute(['active_style' => $newStyle]); $success = "Style switched to " . htmlspecialchars($newStyle) . " successfully."; header("Location: style_switch.php?success=" . urlencode($success)); exit; } else { $error = "Invalid style selected."; } } catch (Exception $e) { $error = "Error: " . $e->getMessage(); } } // Get current active style from the database try { $db = getDbConnection(); $stmt = $db->prepare("SELECT active_style FROM site_config WHERE id = 1"); $stmt->execute(); $config = $stmt->fetch(PDO::FETCH_ASSOC); $activeStyle = $config['active_style'] ?? 'style.css'; } catch (PDOException $e) { $activeStyle = 'style.css'; // Fallback to default $error = "Error fetching style: " . $e->getMessage(); } $pageTitle = "Style Management"; include 'includes/header.php'; ?>