%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64
User : ndkhermy ( 1200)
PHP Version : 8.5.12
Disable Function : NONE
Directory :  /home1/ndkhermy/www/website_6ca89795/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home1/ndkhermy/www/website_6ca89795/wishlist.php
<?php
session_start();
include('header.php'); 

include('dbcon.php');

if (!isset($_SESSION['username']) || !isset($_SESSION['id'])) {
    header('Location: ../login.php'); 
    exit();
}

$username = $_SESSION['username'];
$user_id = $_SESSION['id']; 

$stmt = $conn->prepare("
    SELECT wi.id, wi.product_id, p.price, p.title, p.image 
    FROM wishlist_items wi 
    JOIN areawecover p ON wi.product_id = p.id 
    WHERE wi.user_id = ? 
    ORDER BY wi.id DESC
");
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();

$wishlist_items = [];
$subtotal = 0;

if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $row['price'] = (float)$row['price'];
        $row['total'] = $row['price'];  // As it's a wishlist, the price is already the total for now.
        $wishlist_items[] = $row; 
        $subtotal += $row['total']; 
    }
}

$stmt->close();
$conn->close();
?>

<div id="page-content">
    <div class="collection-header">
        <div class="collection-hero">
            <div class="collection-hero__image"></div>
            <div class="collection-hero__title-wrapper container">
                <h1 class="collection-hero__title">Your Wishlist</h1>
                <div class="breadcrumbs text-uppercase mt-1 mt-lg-2">
                    <a href="index.php" title="Back to the home page">Home</a><span>|</span><span class="fw-bold">Your Wishlist</span>
                </div>
            </div>
        </div>
    </div>

    <div class="container">
        <div class="row">
            <div class="col-12 col-lg-8 main-col">
                <?php if (empty($wishlist_items)) { ?>
                    <div class="alert alert-info">
                        Your wishlist is empty. <a href="../products.php">Browse products</a> to add items to your wishlist.
                    </div>
                <?php } else { ?>
                    <form action="user-update-wishlist.php" method="post" class="wishlist style2">
                        <table class="align-middle">
                            <thead>
                                <tr>
                                    <th class="action">&nbsp;</th>
                                    <th colspan="2" class="text-start">Product</th>
                                    <th class="text-center">Price</th>
                                    <th class="text-center">Add to Cart</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($wishlist_items as $item) { ?>
                                    <tr>
                                        <td class="text-center">
                                            <a href="user-remove-from-wishlist.php?id=<?php echo $item['id']; ?>" class="btn btn--secondary">
                                                <i class="icon an an-times-r"></i>
                                            </a>
                                        </td>
                                        <td>
                                            <a href="../product.php?id=<?php echo $item['product_id']; ?>"><img src="../admin/dataimg/<?php echo htmlspecialchars($item['image']); ?>" alt="<?php echo htmlspecialchars($item['title']); ?>" width="80"></a>
                                        </td>
                                        <td>
                                            <a href="../product.php?id=<?php echo $item['product_id']; ?>"><?php echo htmlspecialchars($item['title']); ?></a>
                                        </td>
                                        <td class="text-center">
                                            $<?php echo number_format($item['price'], 2); ?>
                                        </td>
                                        <td class="text-center">
                                            <a href="user-add-to-cart.php?id=<?php echo $item['product_id']; ?>" class="btn btn--small">Add to Cart</a>
                                        </td>
                                    </tr>
                                <?php } ?>
                            </tbody>
                            <tfoot>
                                <tr>
                                    <td colspan="3">
                                        <a href="../products.php" class="btn btn--link">Continue Shopping</a>
                                    </td>
                                    <td colspan="2" class="text-end">
                                        <div><strong>Total:</strong> $<?php echo number_format($subtotal, 2); ?></div>
                                        <a href="../checkout.php" class="btn btn--small">Proceed to Checkout</a>
                                    </td>
                                </tr>
                            </tfoot>
                        </table>
                    </form>
                <?php } ?>
            </div>
        </div>
    </div>
</div>

<!-- Core JS -->
<script src="../assets/vendor/libs/jquery/jquery.js"></script>
<script src="../assets/vendor/libs/popper/popper.js"></script>
<script src="../assets/vendor/js/bootstrap.js"></script>
<script src="../assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js"></script>
<script src="../assets/vendor/js/menu.js"></script>
<script src="../assets/js/main.js"></script>

</body>
</html>

VaKeR 2022