:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/www/sukhadaworldapp/admin/**
:: Editing File: offer.php
<?php require_once 'db.php'; require_once 'session.php'; include "header.php"; // --- Fetch Message Status --- $status = $_GET['status'] ?? ''; $message = htmlspecialchars($_GET['msg'] ?? ''); // --- Fetch Offer Records --- $offers = []; $sql = "SELECT id, offer_heading, button_text, link, created_at FROM offers ORDER BY id DESC"; $stmt = mysqli_prepare($conn, $sql); if ($stmt) { mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); if ($result && mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { $offers[] = $row; } } mysqli_stmt_close($stmt); } else { $status = 'danger'; $message = 'Database query failed: ' . mysqli_error($conn); } mysqli_close($conn); ?> <!-- PAGE CONTENT --> <div class="page-content-wrapper"> <div class="page-content"> <!-- Breadcrumb --> <div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3"> <div class="breadcrumb-title pe-3">Offers</div> <div class="ps-3"> <nav aria-label="breadcrumb"> <ol class="breadcrumb mb-0 p-0"> <li class="breadcrumb-item"> <a href="dashboard.php"><ion-icon name="home-outline"></ion-icon></a> </li> <li class="breadcrumb-item active">Offer List</li> </ol> </nav> </div> </div> <div class="card"> <div class="card-body"> <!-- Header --> <div class="row mb-3"> <div class="col-sm-9"><h5 class="mb-0">Offer List</h5></div> <div class="col-sm-3 text-end"> <a href="offer_add.php" class="btn btn-primary">Add Offer</a> </div> </div> <!-- Status Alert --> <?php if ($status === 'success'): ?> <div class="alert alert-success alert-dismissible fade show"> <strong>Success:</strong> <?= $message ?> <button type="button" class="btn-close" data-bs-dismiss="alert"></button> </div> <?php elseif ($status === 'danger'): ?> <div class="alert alert-danger alert-dismissible fade show"> <strong>Error:</strong> <?= $message ?> <button type="button" class="btn-close" data-bs-dismiss="alert"></button> </div> <?php endif; ?> <!-- TABLE --> <div class="table-responsive mt-3"> <table class="table align-middle" id="example"> <thead class="table-secondary"> <tr> <th width="60">Sr No</th> <th>Offer Heading</th> <th>Button</th> <th>Link</th> <th>Created At</th> <th class="text-center">Actions</th> </tr> </thead> <tbody> <?php if (empty($offers)): ?> <tr> <td colspan="6" class="text-center">No offers found.</td> </tr> <?php else: ?> <?php $sr = 1; foreach ($offers as $o): ?> <tr> <td><?= $sr++ ?></td> <td><?= htmlspecialchars($o['offer_heading']) ?></td> <td><?= htmlspecialchars($o['button_text']) ?></td> <td><?= htmlspecialchars($o['link']) ?></td> <td><?= htmlspecialchars($o['created_at']) ?></td> <td class="text-center"> <div class="d-flex justify-content-center gap-3"> <a href="offer_edit.php?id=<?= $o['id'] ?>" title="Edit"> <ion-icon name="create-outline"></ion-icon> </a> <a href="offer_delete.php?id=<?= $o['id'] ?>" onclick="return confirm('Are you sure you want to delete this offer?')" class="text-danger" title="Delete"> <ion-icon name="trash-outline"></ion-icon> </a> </div> </td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> </div> </div> <?php include "footer.php"; ?> <!-- DataTables --> <script src="assets/plugins/datatable/js/jquery.dataTables.min.js"></script> <script src="assets/plugins/datatable/js/dataTables.bootstrap5.min.js"></script> <script src="assets/js/table-datatable.js"></script>