D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
tresboutique.in
/
tresadmin
/
Filename :
products.php
back
Copy
<?php include 'config.php'; if (isset($_POST['delete_product'])) { $id = $_POST['product_id']; // Ensure the ID is numeric to prevent SQL injection if (is_numeric($id)) { $deleteQuery = "DELETE FROM products WHERE product_id = ?"; $stmt = $conn->prepare($deleteQuery); $stmt->bind_param("i", $id); if ($stmt->execute()) { // Delete the associated image from the server as well (optional) // You may want to handle this part based on your server's image storage strategy $stmt->close(); header("Location: products.php?message=Product Deleted Successfully"); exit(); } else { echo "Error: " . $stmt->error; } } else { echo "Invalid product ID."; } } ?> <!DOCTYPE html> <html lang="en"> <head> <?php require('style.php') ?> </head> <body onload="startTime()"> <div class="page-wrapper compact-wrapper" id="pageWrapper"> <!-- Page Header Start--> <div class="page-header"> <div class="header-wrapper row m-0"> <div class="header-logo-wrapper col-auto p-0"> <div class="logo-wrapper"><a href="index.php"><img class="img-fluid for-light" src="assets/images/newpclogo.png" alt=""><img class="img-fluid for-dark" src="assets/images/newpclogo.png" alt=""></a></div> </div> <div class="left-header col-xxl-5 col-xl-6 col-md-4 col-auto box-col-6 horizontal-wrapper p-0"> <div class="left-menu-header"> <ul class="header-left"> <li> <div class="form-group w-100"> <div class="Typeahead Typeahead--twitterUsers"> <div class="u-posRelative d-flex"> <svg class="search-bg svg-color me-2"> <use href="https://admin.pixelstrap.net/crocsassets/svg/icon-sprite.svg#fill-search"></use> </svg> <input class="demo-input py-0 Typeahead-input form-control-plaintext w-100" type="text" placeholder="Search anything..." name="q" title=""> </div> </div> </div> </li> </ul> </div> </div> <div class="nav-right col-xxl-7 col-xl-6 col-auto box-col-6 pull-right right-header p-0 ms-auto"> <ul class="nav-menus"> <li class="serchinput"> <div class="serchbox"> <svg> <use href="https://admin.pixelstrap.net/crocsassets/svg/icon-sprite.svg#fill-search"></use> </svg> </div> <div class="form-group search-form"> <input type="text" placeholder="Search here..."> </div> </li> <li> <div class="mode"> <svg> <use href="https://admin.pixelstrap.net/crocsassets/svg/icon-sprite.svg#fill-dark"></use> </svg> </div> </li> <li class="profile-nav onhover-dropdown p-0"> <div class="d-flex align-items-center profile-media"><img class="b-r-10 img-40" src="assets/images/dashboard/profile.png" alt="Profile"> <div class="flex-grow-1"><span>Tres Boutique</span> </div> </div> </li> </ul> </div> </div> </div> <!-- Page Header Ends --> <!-- Page Body Start--> <div class="page-body-wrapper"> <!-- Page Sidebar Start--> <?php require('sidebar.php') ?> <!-- Page Sidebar Ends--> <div class="page-body"> <div class="container-fluid"> <div class="page-title"> <div class="row"> <div class="col-sm-6 p-0"> <h3>Products Dashboard</h3> </div> </div> </div> </div> <!-- Container-fluid starts--> <div class="container-fluid default-dashboard"> <div class="row"> <div class="col-sm-12"> <div class="card"> <div class="card-body"> <!-- Display success message after deletion --> <?php if (isset($_GET['message'])): ?> <div class="alert alert-success"> <?php echo $_GET['message']; ?> </div> <?php endif; ?> <div class="list-product"> <table class="table" id="project-status"> <thead> <tr> <th>ID</th> <th>Image</th> <th>Name</th> <th>Category</th> <th>Price</th> <th>Actions</th> </tr> </thead> <tbody> <?php $query = "SELECT p.product_id, p.product_name, p.product_price, p.product_img_1, c.product_category_name FROM products p LEFT JOIN product_category c ON p.product_category = c.product_category_id"; $result = mysqli_query($conn, $query); while ($item = mysqli_fetch_assoc($result)) { $id = $item['product_id']; $imageSrc = htmlspecialchars($item['product_img_1'], ENT_QUOTES, 'UTF-8'); ?> <tr> <td><?php echo $id; ?></td> <td><img src="uploads/products/<?php echo $imageSrc; ?>" alt="Product Image" width="100px"></td> <td><?php echo htmlspecialchars($item['product_name'], ENT_QUOTES, 'UTF-8'); ?></td> <td><?php echo htmlspecialchars($item['product_category_name'], ENT_QUOTES, 'UTF-8'); ?></td> <td>₹<?php echo htmlspecialchars($item['product_price'], ENT_QUOTES, 'UTF-8'); ?></td> <td> <a href="edit_product.php?product_id=<?php echo $id; ?>" class="btn btn-success"><i class='bx bx-edit'></i></a> <form action="" method="POST" style="display:inline;"> <input type="hidden" name="product_id" value="<?php echo $id; ?>"> <button type="submit" name="delete_product" class="btn btn-danger"><i class='bx bxs-trash'></i></button> </form> </td> </tr> <?php } ?> </tbody> </table> </div> </div> </div> </div> </div> </div> <!-- Container-fluid Ends--> </div> </div> </div> <!-- latest jquery--> <?php require('footer.php') ?> <!-- Plugin used--> </body> </html>