<?php
include '../includes/db.php';
include_once __DIR__ . '/../includes/permissions.php';
session_start();
require_permission('about_page_edit');
// Data from form
$content_updates = [
'hero' => [
'title' => $_POST['hero_title'],
'content' => $_POST['hero_content'],
'image_url' => '' // No image for hero section
],
'story' => [
'title' => $_POST['story_title'],
'content' => $_POST['story_content'],
'image_url' => $_POST['story_image_url']
],
'vision' => [
'title' => $_POST['vision_title'],
'content' => $_POST['vision_content'],
'image_url' => $_POST['vision_image_url']
]
];
// Prepare statement
$stmt = $conn->prepare("UPDATE about_content SET title = ?, content = ?, image_url = ? WHERE section = ?");
foreach ($content_updates as $section => $data) {
$stmt->bind_param("ssss", $data['title'], $data['content'], $data['image_url'], $section);
$stmt->execute();
}
$stmt->close();
$conn->close();
// Redirect back to the edit page with a success message
header("Location: about_edit.php?success=1");
exit();
} else {
// If not a POST request, redirect to the edit page
header("Location: about_edit.php");
exit();
}
?>