uawdijnntqw1x1x1
IP : 216.73.216.93
Hostname : panel.codeskitter.com
Kernel : Linux panel.codeskitter.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
Disable Function : apache_child_terminate, apache_note, apache_setenv, define_syslog_variables, dl, link, opcache_get_status, openlog, pcntl_exec, pcntl_fork, pcntl_setpriority, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid
OS : Linux
PATH:
/
home
/
users
/
unlimited
/
www
/
.
/
nigeria.codeskitter.site
/
admin
/
categories.php
/
/
<?php include '../includes/config.php'; if(!isset($_SESSION['user_id']) || $_SESSION['user_role'] != 'admin') { header("Location: login.php"); exit(); } // Handle form submissions if($_SERVER['REQUEST_METHOD'] == 'POST') { if(isset($_POST['add_category'])) { $name = $_POST['name']; $description = $_POST['description']; $sql = "INSERT INTO categories (name, description) VALUES (?, ?)"; $stmt = $conn->prepare($sql); $stmt->bind_param("ss", $name, $description); $stmt->execute(); } if(isset($_POST['delete_category'])) { $category_id = $_POST['category_id']; $sql = "DELETE FROM categories WHERE id = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param("i", $category_id); $stmt->execute(); } if(isset($_POST['update_category'])) { $category_id = $_POST['category_id']; $name = $_POST['name']; $description = $_POST['description']; $sql = "UPDATE categories SET name = ?, description = ? WHERE id = ?"; $stmt = $conn->prepare($sql); $stmt->bind_param("ssi", $name, $description, $category_id); $stmt->execute(); } } $categories = $conn->query("SELECT * FROM categories ORDER BY created_at DESC"); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Manage Categories - Admin</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css"> </head> <body> <div class="container-fluid"> <div class="row"> <?php include 'sidebar.php'; ?> <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4"> <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"> <h1 class="h2">Manage Categories</h1> <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addCategoryModal"> <i class="bi bi-plus-circle"></i> Add New Category </button> </div> <!-- Categories Table --> <div class="card"> <div class="card-body"> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Description</th> <th>Created At</th> <th>Actions</th> </tr> </thead> <tbody> <?php while($category = $categories->fetch_assoc()): ?> <tr> <td><?php echo $category['id']; ?></td> <td><?php echo $category['name']; ?></td> <td><?php echo $category['description']; ?></td> <td><?php echo date('M j, Y', strtotime($category['created_at'])); ?></td> <td> <div class="btn-group"> <button class="btn btn-sm btn-outline-primary edit-category" data-bs-toggle="modal" data-bs-target="#editCategoryModal" data-id="<?php echo $category['id']; ?>" data-name="<?php echo $category['name']; ?>" data-description="<?php echo $category['description']; ?>"> <i class="bi bi-pencil"></i> </button> <form method="POST" class="d-inline"> <input type="hidden" name="category_id" value="<?php echo $category['id']; ?>"> <button type="submit" name="delete_category" class="btn btn-sm btn-outline-danger" onclick="return confirm('Are you sure you want to delete this category?')"> <i class="bi bi-trash"></i> </button> </form> </div> </td> </tr> <?php endwhile; ?> </tbody> </table> </div> </div> </div> </main> </div> </div> <!-- Add Category Modal --> <div class="modal fade" id="addCategoryModal" tabindex="-1"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Add New Category</h5> <button type="button" class="btn-close" data-bs-dismiss="modal"></button> </div> <form method="POST"> <div class="modal-body"> <div class="mb-3"> <label class="form-label">Category Name</label> <input type="text" class="form-control" name="name" required> </div> <div class="mb-3"> <label class="form-label">Description</label> <textarea class="form-control" name="description" rows="3"></textarea> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> <button type="submit" name="add_category" class="btn btn-primary">Add Category</button> </div> </form> </div> </div> </div> <!-- Edit Category Modal --> <div class="modal fade" id="editCategoryModal" tabindex="-1"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Edit Category</h5> <button type="button" class="btn-close" data-bs-dismiss="modal"></button> </div> <form method="POST"> <div class="modal-body"> <input type="hidden" name="category_id" id="edit_category_id"> <div class="mb-3"> <label class="form-label">Category Name</label> <input type="text" class="form-control" name="name" id="edit_category_name" required> </div> <div class="mb-3"> <label class="form-label">Description</label> <textarea class="form-control" name="description" id="edit_category_description" rows="3"></textarea> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> <button type="submit" name="update_category" class="btn btn-primary">Update Category</button> </div> </form> </div> </div> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> <script> // Edit category functionality document.querySelectorAll('.edit-category').forEach(button => { button.addEventListener('click', function() { const id = this.getAttribute('data-id'); const name = this.getAttribute('data-name'); const description = this.getAttribute('data-description'); document.getElementById('edit_category_id').value = id; document.getElementById('edit_category_name').value = name; document.getElementById('edit_category_description').value = description; }); }); </script> </body> </html>
/home/users/unlimited/www/./nigeria.codeskitter.site/admin/categories.php