File manager - Edit - /home/webapp68.cm.in.th/u68319090003/Final/Final/admin/delete_article.php
Back
<?php session_start(); if (!isset($_SESSION['user_id']) || $_SESSION['role'] != 'teacher') { header("Location: ../login.php"); exit(); } include(__DIR__ . '/../config/db.php'); $id = intval($_GET['id'] ?? 0); // ถ้าไม่มี id → กลับไป dashboard if ($id <= 0) { header("Location: dashboard.php"); exit(); } // ถ้ากดปุ่มยืนยันลบ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $stmt = $conn->prepare("DELETE FROM articles WHERE id = ?"); $stmt->bind_param("i", $id); $stmt->execute(); $stmt->close(); header("Location: dashboard.php?msg=deleted"); exit(); } ?> <!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <title>ยืนยันการลบข่าว</title> <style> body { font-family: 'Prompt', sans-serif; background: #f3f4f6; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .confirm-box { background: #fff; padding: 30px; border-radius: 12px; box-shadow: 0 8px 25px rgba(0,0,0,0.15); text-align: center; max-width: 400px; width: 90%; } h2 { margin-bottom: 15px; color: #dc2626; } p { margin-bottom: 25px; color: #444; } .btn { display: inline-block; padding: 10px 18px; margin: 5px; border-radius: 8px; font-size: 16px; text-decoration: none; transition: background 0.3s; } .btn-cancel { background: #6b7280; color: #fff; } .btn-cancel:hover { background: #4b5563; } .btn-confirm { background: #dc2626; color: #fff; } .btn-confirm:hover { background: #991b1b; } </style> </head> <body> <div class="confirm-box"> <h2>⚠️ ยืนยันการลบ</h2> <p>คุณแน่ใจหรือไม่ว่าต้องการลบข่าว <br><strong>ID: <?php echo $id; ?></strong> ?</p> <form method="post"> <button type="submit" class="btn btn-confirm">✅ ยืนยันลบ</button> <a href="dashboard.php" class="btn btn-cancel">❌ ยกเลิก</a> </form> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.42 |
proxy
|
phpinfo
|
Settings