diff --git a/admin/addapp.php b/admin/addapp.php index 4a0e719..e0e4799 100644 --- a/admin/addapp.php +++ b/admin/addapp.php @@ -87,10 +87,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_app'])) { } } - header('Location: index.php?success=App 添加成功'); + echo ''; exit; } else { - $error = 'App 添加失败: '. $conn->error; + echo ''; } } } diff --git a/admin/announcements.php b/admin/announcements.php index d394f30..477cce2 100644 --- a/admin/announcements.php +++ b/admin/announcements.php @@ -17,14 +17,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $stmt = $conn->prepare('INSERT INTO announcements (title, content, admin_id) VALUES (?, ?, ?)'); $stmt->bind_param('ssi', $title, $content, $admin_id); if ($stmt->execute()) { - header('Location: announcements.php?success=公告发布成功'); + echo ''; exit; } else { - $error = '公告发布失败: ' . $conn->error; + echo ''; } $stmt->close(); } else { - $error = '标题和内容不能为空'; + echo ''; } } diff --git a/admin/deleteapp.php b/admin/deleteapp.php index 9d05f8b..c26594c 100644 --- a/admin/deleteapp.php +++ b/admin/deleteapp.php @@ -10,7 +10,7 @@ if (!isset($_SESSION['admin'])) { // 验证App ID if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { - header('Location: index.php?error=无效的App ID'); + echo ''; exit; } $appId = $_GET['id']; @@ -33,9 +33,9 @@ if ($stmt->execute() === TRUE) { $verStmt->bind_param("i", $appId); $verStmt->execute(); - header('Location: index.php?success=App 删除成功'); + echo ''; } else { - header('Location: index.php?error=App 删除失败: '. $conn->error); + echo ''; } exit; ?> \ No newline at end of file diff --git a/admin/editapp.php b/admin/editapp.php index cced6d7..f85b817 100644 --- a/admin/editapp.php +++ b/admin/editapp.php @@ -10,7 +10,7 @@ if (!isset($_SESSION['admin'])) { // 验证App ID if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { - header('Location: index.php?error=无效的App ID'); + echo ''; exit; } $appId = $_GET['id']; @@ -23,7 +23,7 @@ $stmt->bind_param("i", $appId); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows === 0) { - header('Location: index.php?error=App不存在'); + echo ''; exit; } $app = $result->fetch_assoc(); @@ -99,11 +99,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_app'])) { $stmt->close(); } - header('Location: index.php?success=App 更新成功'); - exit; - } else { - $error = 'App 更新失败: '. $conn->error; - } + $updateAppSql = "UPDATE apps SET name = ?, description = ?, age_rating = ?, platforms = ? WHERE id = ?"; + $updateStmt = $conn->prepare($updateAppSql); + $updateStmt->bind_param("ssssi", $name, $description, $ageRating, $newPlatforms, $appId); + if ($updateStmt->execute() === TRUE) { + echo ''; + exit; + } else { + echo ''; + } + $updateStmt->close(); + } } ?> @@ -391,5 +397,4 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_app'])) { $stmt = $conn->prepare("UPDATE apps SET name=?, description=?, age_rating=?, age_rating_description=?, platforms=?, updated_at=NOW() WHERE id=?"); $stmt->bind_param("sssssi", $name, $description, $age_rating, $_POST['age_rating_description'], $platformsJson, $appId); -// ... existing code ... ?> \ No newline at end of file diff --git a/admin/index.php b/admin/index.php index 12ac45a..285a487 100644 --- a/admin/index.php +++ b/admin/index.php @@ -30,7 +30,7 @@ $resultApps = $conn->query($sqlApps); if (!$resultApps) { error_log("Database query failed: " . $conn->error); - echo '