/
/
home
/
u523034047
/
domains
/
nainitalfloweritech.com
/
public_html
/
admin
Server: in-mum-web1112.main-hosting.eu (62.72.28.111)
You: 216.73.216.89
PHP 8.3.16
Dir:
/home/u523034047/domains/nainitalfloweritech.com/public_html/admin
Edit:
/home/u523034047/domains/nainitalfloweritech.com/public_html/admin/manage-products.php
<?php session_start(); include('include/config.php'); include('include/admin-menu.php'); if (empty($_SESSION['alogin'])) { header('Location: index.php'); exit(); } date_default_timezone_set('Asia/Kolkata'); /* ===== DELETE PRODUCT (SECURE) ===== */ if (isset($_GET['del'], $_GET['id'])) { $id = intval($_GET['id']); $stmt = $con->prepare("DELETE FROM products WHERE id = ?"); $stmt->bind_param("i", $id); if ($stmt->execute()) { $_SESSION['delmsg'] = "Product deleted successfully!"; } else { $_SESSION['delmsg'] = "Failed to delete product!"; } header("Location: manage-products.php"); exit(); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Admin | Manage Products</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Bootstrap 5 --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> <!-- FontAwesome --> <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" rel="stylesheet"> <!-- DataTables --> <link href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css" rel="stylesheet"> <style> body{ min-height:100vh; background: linear-gradient(135deg, #667eea, #764ba2); font-family: 'Segoe UI', sans-serif; } .admin-wrapper{ padding:25px; } .top-bar{ background:#4f46e5; color:#fff; padding:15px 25px; border-radius:12px; display:flex; justify-content:space-between; align-items:center; box-shadow:0 10px 25px rgba(0,0,0,.2); } .top-bar h4{ margin:0; } .card-panel{ background:#fff; border-radius:12px; box-shadow:0 15px 40px rgba(0,0,0,.2); padding:20px; margin-top:20px; } .table thead{ background:#4f46e5; color:#fff; } .badge-custom{ background:#4f46e5; } .action-btn{ border-radius:8px; } .footer-text{ text-align:center; color:#eee; font-size:13px; margin-top:20px; } </style> </head> <body> <div class="container py-5"> <!-- Main Card --> <div class="card-panel"> <?php if (!empty($_SESSION['delmsg'])) { ?> <div class="alert alert-success text-center"> <?php echo htmlentities($_SESSION['delmsg']); ?> </div> <?php $_SESSION['delmsg'] = ""; } ?> <div class="table-responsive"> <table id="productTable" class="table table-striped table-bordered align-middle"> <thead> <tr> <th>#</th> <th>Product</th> <th>Category</th> <th>Subcategory</th> <th>Company</th> <th>Created On</th> <th width="120">Action</th> </tr> </thead> <tbody> <?php $query = $con->query(" SELECT p.id, p.productName, p.productCompany, p.postingDate, c.categoryName, s.subcategory FROM products p JOIN category c ON c.id = p.category JOIN subcategory s ON s.id = p.subCategory "); $cnt = 1; while ($row = $query->fetch_assoc()) { ?> <tr> <td><?php echo $cnt++; ?></td> <td><strong><?php echo htmlentities($row['productName']); ?></strong></td> <td><span class="badge badge-custom"><?php echo htmlentities($row['categoryName']); ?></span></td> <td><?php echo htmlentities($row['subcategory']); ?></td> <td><?php echo htmlentities($row['productCompany']); ?></td> <td><?php echo htmlentities($row['postingDate']); ?></td> <td> <a href="edit-products.php?id=<?php echo $row['id']; ?>" class="btn btn-info btn-sm action-btn" title="Edit"> <i class="fa fa-pen"></i> </a> <a href="manage-products.php?id=<?php echo $row['id']; ?>&del=1" class="btn btn-danger btn-sm action-btn" onclick="return confirm('Are you sure you want to delete this product?');" title="Delete"> <i class="fa fa-trash"></i> </a> </td> </tr> <?php } ?> </tbody> </table> </div> </div> </div> <!-- Scripts --> <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script> <script> $(document).ready(function(){ $('#productTable').DataTable({ pageLength: 10, order: [[0,'desc']], language:{ search:"Search Product:", lengthMenu:"Show _MENU_ entries" } }); }); </script> </body> </html>
Ukuran: 4.9 KB