38961-vm/admin_edit.php
2026-03-04 08:52:30 +00:00

44 lines
1.5 KiB
PHP

<?php
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/db/content_manager.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$key = $_POST['key'];
$title = $_POST['title'];
$content = $_POST['content'];
update_content($key, $title, $content);
header('Location: admin_edit.php?updated=1');
exit;
}
$all_content = db()->query("SELECT * FROM site_content")->fetchAll();
?>
<!DOCTYPE html>
<html>
<head>
<title>Admin Edit Content</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light p-5">
<div class="container">
<h1>Edit Page Content</h1>
<?php foreach ($all_content as $item): ?>
<div class="card my-3 p-3">
<form method="POST">
<input type="hidden" name="key" value="<?= $item['section_key'] ?>">
<div class="mb-2">
<label>Title</label>
<input type="text" name="title" class="form-control" value="<?= htmlspecialchars($item['title']) ?>">
</div>
<div class="mb-2">
<label>Content</label>
<textarea name="content" class="form-control"><?= htmlspecialchars($item['content']) ?></textarea>
</div>
<button type="submit" class="btn btn-primary">Save Changes</button>
</form>
</div>
<?php endforeach; ?>
</div>
</body>
</html>