if(isset($_POST['save']) && $_SESSION['role'] === 'admin') { $id = $_POST['id'] ?? null; $title = $_POST['title']; $content = $_POST['content']; $image = $_POST['image_url']; if($id) { $stmt = $pdo->prepare("UPDATE news SET title=?, content=?, image_url=?, updated_at=NOW() WHERE id=?"); $stmt->execute([$title, $content, $image, $id]); } else { $stmt = $pdo->prepare("INSERT INTO news (title, content, image_url) VALUES (?, ?, ?)"); $stmt->execute([$title, $content, $image]); } // Обновляем HTML-файлы include 'generate_news_html.php'; header('Location: admin.php'); exit; }