Live Editor
Editor Locked
Please log in or create an account to edit the page content.
prepare("SELECT content FROM user_content WHERE user_id = ?"); $stmt->execute([$_SESSION['user_id']]); $user_content_row = $stmt->fetch(); if ($user_content_row) { $content = json_decode($user_content_row['content'], true); } else { // New user, so create default content for them $default_content_json = file_get_contents('db/content.json'); $content = json_decode($default_content_json, true); $insert_stmt = $pdo->prepare("INSERT INTO user_content (user_id, content) VALUES (?, ?)"); $insert_stmt->execute([$_SESSION['user_id'], $default_content_json]); } } else { // User is not logged in, show default content $content = json_decode(file_get_contents('db/content.json'), true); } // Handle content updates if ($_SERVER['REQUEST_METHOD'] === 'POST' && $is_logged_in) { $pdo = db(); // Fetch existing content to merge $stmt = $pdo->prepare("SELECT content FROM user_content WHERE user_id = ?"); $stmt->execute([$_SESSION['user_id']]); $current_content_json = $stmt->fetchColumn(); $current_content = json_decode($current_content_json, true); // Update with new values from POST $current_content['hero_title'] = $_POST['hero_title'] ?? $current_content['hero_title']; $current_content['hero_subtitle'] = $_POST['hero_subtitle'] ?? $current_content['hero_subtitle']; $current_content['features_title'] = $_POST['features_title'] ?? $current_content['features_title']; $current_content['feature_1_title'] = $_POST['feature_1_title'] ?? $current_content['feature_1_title']; $current_content['feature_1_text'] = $_POST['feature_1_text'] ?? $current_content['feature_1_text']; $current_content['feature_2_title'] = $_POST['feature_2_title'] ?? $current_content['feature_2_title']; $current_content['feature_2_text'] = $_POST['feature_2_text'] ?? $current_content['feature_2_text']; $current_content['feature_3_title'] = $_POST['feature_3_title'] ?? $current_content['feature_3_title']; $current_content['feature_3_text'] = $_POST['feature_3_text'] ?? $current_content['feature_3_text']; $current_content['about_title'] = $_POST['about_title'] ?? $current_content['about_title']; $current_content['about_text'] = $_POST['about_text'] ?? $current_content['about_text']; $new_content_json = json_encode($current_content, JSON_PRETTY_PRINT); // Update the database $update_stmt = $pdo->prepare("UPDATE user_content SET content = ? WHERE user_id = ?"); $update_stmt->execute([$new_content_json, $_SESSION['user_id']]); // Redirect to avoid form resubmission header("Location: " . $_SERVER['PHP_SELF']); exit; } // Default values $hero_title = htmlspecialchars($content['hero_title'] ?? 'Build Your Dream Website'); $hero_subtitle = htmlspecialchars($content['hero_subtitle'] ?? 'Visually design, customize, and publish beautiful, responsive websites. No code required.'); $features_title = htmlspecialchars($content['features_title'] ?? 'Features'); $feature_1_title = htmlspecialchars($content['feature_1_title'] ?? 'Visual Editor'); $feature_1_text = htmlspecialchars($content['feature_1_text'] ?? 'Design and customize your site with a powerful, intuitive drag-and-drop editor.'); $feature_2_title = htmlspecialchars($content['feature_2_title'] ?? 'Responsive Templates'); $feature_2_text = htmlspecialchars($content['feature_2_text'] ?? 'Start with professionally designed, mobile-friendly templates that look great on any device.'); $feature_3_title = htmlspecialchars($content['feature_3_title'] ?? 'One-Click Publishing'); $feature_3_text = htmlspecialchars($content['feature_3_text'] ?? 'Go live instantly. We handle the hosting, security, and scaling for you.'); $about_title = htmlspecialchars($content['about_title'] ?? 'About Us'); $about_text = htmlspecialchars($content['about_text'] ?? 'We believe creating a website should be simple and accessible to everyone. Our mission is to empower creators with tools that are both powerful and easy to use.'); ?>
Please log in or create an account to edit the page content.