后台管理 - 发布文章

登录后访问此页面。

"; exit; } $stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?"); $stmt->execute([$_SESSION['user_id']]); $user = $stmt->fetch(); if ($user['group'] !== 'admin') { echo "

您没有权限访问此页面。

"; exit; } // 发布文章逻辑 if ($_SERVER['REQUEST_METHOD'] == 'POST') { $title = $_POST['title']; $content = $_POST['content']; $type = $_POST['type']; // 获取文章类型 $stmt = $pdo->prepare("INSERT INTO articles (title, content, type, created_at) VALUES (?, ?, ?, NOW())"); if ($stmt->execute([$title, $content, $type])) { echo "

文章发布成功!

"; } else { echo "

文章发布失败!

"; } } ?>