D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
siliguritoys.com
/
Filename :
index.php
back
Copy
<?php session_start(); include 'config.php'; // Database connection // Assuming user is logged in and we have their ID stored in session $user_id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 0; // Generate CSRF token if not already set if (empty($_SESSION['csrf_token'])) { $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); } // Fetch only 4 categories $categoryQuery = "SELECT category_id, category_name FROM product_category LIMIT 3"; $categoryResult = mysqli_query($conn, $categoryQuery); // Fetch products with wishlist status $query = "SELECT p.*, c.category_name, IFNULL((SELECT COUNT(*) FROM product_wishlist w WHERE w.user_id = ? AND w.product_id = p.id), 0) AS is_wishlisted FROM slgtoys_products p JOIN product_category c ON p.category_id = c.category_id LIMIT 6"; // Limit to 6 products $stmt = $conn->prepare($query); if ($stmt) { $stmt->bind_param("i", $user_id); $stmt->execute(); $productResult = $stmt->get_result(); } else { die("Query preparation failed: " . mysqli_error($conn)); } ?> <!DOCTYPE html> <html class="no-js" lang="zxx"> <head> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> </head> <body> <!-- header --> <?php include 'header.php'; include 'style.php'; ?> <!-- header --> <!-- Carousal --> <div class="ot-hero-wrapper hero-1" id="hero"> <div class="hero-shape1 ripple-animation"><img src="assets/img/hero/hero-shape1-1.png" alt="img" /></div> <div class="hero-shape2 ripple-animation"><img src="assets/img/hero/hero-shape1-1.png" alt="img" /></div> <div class="hero-inner"> <div class="container"> <div class="row gy-40"> <div class="col-xxl-12"> <div class="hero-wrap1" data-bg-src="assets/img/hero/hero-bg1-1.png"> <div class="hero-shape3 jump d-sm-block d-none"><img src="assets/img/hero/hero-shape1-2.png" alt="img" data-cue="slideInUp" data-delay="500" /></div> <div class="hero-style1"> <span class="sub-title" data-cue="slideInUp">Up to 70% Off On Our Products</span> <h1 class="hero-title text-white"><span class="title1" data-cue="slideInUp" data-delay="100">Buy All Type Of Toys </span><span class="title2" data-cue="slideInUp" data-delay="200">in One Roof</span></h1> <div class="btn-group" data-cue="slideInUp" data-delay="300"> <a href="shop.php" class="ot-btn style-white">Shop Now <i class="fas fa-arrow-right ms-2"></i></a> </div> </div> <div class="hero-thumb1-1" data-cue="slideInUp" data-delay="200"> <img src="assets/img/hero/hero-thumb1-1.png" alt="img" /> <div class="hero-shape1-3 jump-reverse"><img src="assets/img/hero/hero-shape1-3.png" alt="img" /></div> <div class="hero-shape1-4 jump"><img src="assets/img/hero/hero-shape1-4.png" alt="img" /></div> </div> </div> </div> </div> </div> </div> </div> <!-- Carousal --> <section class="mt-60 mb-60"> <div class="container"> <div class="row gy-4"> <div class="col-lg-3 col-sm-6" data-cue="slideInUp"> <div class="feature-list" data-theme-color="#00BBAE"> <div class="box-icon"><img src="assets/img/icon/feature-icon1-1.svg" alt="icon" /></div> <div class="media-body"> <h3 class="box-title">Return & refund</h3> <p class="box-text">Money back guarantee</p> </div> </div> </div> <div class="col-lg-3 col-sm-6" data-cue="slideInUp"> <div class="feature-list" data-theme-color="#C062D0"> <div class="box-icon"><img src="assets/img/icon/feature-icon1-2.svg" alt="icon" /></div> <div class="media-body"> <h3 class="box-title">Secure Payment</h3> <p class="box-text">30% off by subscribing</p> </div> </div> </div> <div class="col-lg-3 col-sm-6" data-cue="slideInUp"> <div class="feature-list" data-theme-color="#71D863"> <div class="box-icon"><img src="assets/img/icon/feature-icon1-3.svg" alt="icon" /></div> <div class="media-body"> <h3 class="box-title">Quality Support</h3> <p class="box-text">Always online 24/7</p> </div> </div> </div> <div class="col-lg-3 col-sm-6" data-cue="slideInUp"> <div class="feature-list" data-theme-color="#16C4E3"> <div class="box-icon"><img src="assets/img/icon/feature-icon1-4.svg" alt="icon" /></div> <div class="media-body"> <h3 class="box-title">Daily Offers</h3> <p class="box-text">20% off by subscribing</p> </div> </div> </div> </div> </div> </section> <!-- Trending Items --> <?php // Fetch only 4 categories $categoryQuery = "SELECT category_id, category_name FROM product_category LIMIT 3"; $categoryResult = mysqli_query($conn, $categoryQuery); // Fetch products (limit to 6 for 'All Items') $productQuery = "SELECT p.id, p.name, p.image_1, p.price, p.category_id FROM slgtoys_products p LIMIT 4"; $productResult = mysqli_query($conn, $productQuery); ?> <!-- Trending Items --> <section class="mt-60 mb-60"> <div class="container"> <div class="row justify-content-xl-between justify-content-center align-items-center"> <div class="col-xl-4 col-lg-6 col-md-8"> <div class="title-area text-xl-start text-center"> <h2 class="sec-title" data-cue="slideInUp">Trending Items</h2> </div> </div> <div class="col-xl-auto"> <div class="sec-btn"> <div class="filter-menu indicator-active filter-menu-active justify-content-center"> <button data-filter="*" class="link-btn tab-btn active" type="button" data-cue="slideInUp">All Items</button> <?php while ($category = mysqli_fetch_assoc($categoryResult)) { ?> <button data-filter=".cat<?= $category['category_id'] ?>" class="link-btn tab-btn" type="button" data-cue="slideInUp"> <?= htmlspecialchars($category['category_name']) ?> </button> <?php } ?> </div> </div> </div> </div> <div class="row gy-30 justify-content-center"> <div class="col-xxl-9 col-12"> <div class="row gy-30 filter-active"> <?php while ($row = mysqli_fetch_assoc($productResult)) { $categoryClass = "cat" . $row['category_id']; $isWishlisted = isset($row['is_wishlisted']) ? $row['is_wishlisted'] : 0; // Default to 0 if not set ?> <div class="col-xl-3 col-md-6 filter-item <?= $categoryClass ?>"> <div class="ot-product product-grid style4" data-cue="slideInUp"> <div class="product-img"> <a href="product-details.php?id=<?= $row['id'] ?>"> <img src="slgadmintoys/<?= $row['image_1'] ?>" alt="<?= htmlspecialchars($row['name']) ?>" /> </a> <div class="actions"> <a href="javascript:void(0);" class="icon-btn wishlist-btn <?php echo ($isWishlisted > 0) ? 'active' : '0'; ?>" data-product-id="<?php echo $row['id']; ?>"> <i class="fa <?php echo ($isWishlisted > 0) ? 'fa-heart' : 'fa-heart-o'; ?>"></i> </a> </div> </div> <div class="product-content"> <h3 class="box-title"> <a href="product-details.php?id=<?= $row['id'] ?>"> <?= htmlspecialchars($row['name']) ?> </a> </h3> <div class="product-content-meta"> <span class="price">Rs.<?= $row['price'] ?></span> </div> <button class="ot-btn mt-10 add-to-cart" data-product-id="<?php echo $row['id']; ?>"> <i class="fa-light fa-basket-shopping me-1"></i> Add To Cart </button> </div> </div> </div> <?php } ?> </div> </div> <div class="col-xxl-3 col-xl-6 col-lg-8"> <div class="cta-box3 mega-hover" data-bg-src="assets/img/bg/cta_bg_5_1.png"> <div class="box-content"> <h3 class="box-title text-white" data-cue="slideInUp">Kid Fashion<br /> for Store</h3> <div class="box-subtitle text-white" data-cue="slideInUp" data-delay="100">And get your 25% discount now!</div> <a href="shop.php" class="ot-btn style-white" data-cue="slideInUp" data-delay="200">Shop Now<i class="fas fa-arrow-right ms-2"></i></a> </div> <div class="offer-thumb" data-cue="slideInUp" data-delay="100"> <img src="assets/img/normal/cta-thumb5-1.png" alt="img" /> </div> </div> </div> </div> </div> </section> <!-- Trending Items --> <!-- baneer --> <section class="mt-60 mb-60"> <div class="container z-index-common"> <div class="cta-box position-relative" data-bg-src="assets/img/bg/cta_bg_2_1.png"> <div class="body-particle" id="cta-particle"></div> <div class="row"> <div class="col-xl-6"> <div class="box-content text-xl-start text-center"> <div class="title-area mb-30" data-cue="slideInUp"> <h2 class="sec-title text-white"> Get 45% discount in all of<br class="d-xxl-block d-none" /> Our super Toys </h2> </div> <a href="shop.php" class="ot-btn style-white" data-cue="slideInUp" data-delay="100">Shop Now<i class="fas fa-arrow-right ms-2"></i></a> </div> </div> <div class="col-xl-6 align-self-end"> <div class="cta-thumb2-1 text-xl-end text-center" data-cue="slideInUp" data-delay="100"><img src="assets/img/normal/cta-thumb2-1.png" alt="img" /></div> </div> </div> </div> </div> </section> <!-- baneer --> <!-- shop by category --> <?php $query = "SELECT category_id, category_name, category_image FROM product_category"; $result = mysqli_query($conn, $query); ?> <section class="space-bottom overflow-hidden"> <div class="container"> <div class="row justify-content-center"> <div class="col-xl-4 col-lg-6 col-md-8"> <div class="title-area text-center"> <h2 class="sec-title" data-cue="slideInUp">Shop by Category</h2> <p class="sec-text" data-cue="slideInUp" data-delay="100"> Explore a wide range of toys for every interest, making it easy to find the perfect playtime companion at Siliguri Toys. </p> </div> </div> </div> <div class="slider-area"> <div class="swiper ot-slider" id="categorySlider1" data-slider-options='{"breakpoints":{"0":{"slidesPerView":2},"400":{"slidesPerView":2},"768":{"slidesPerView":3},"992":{"slidesPerView":4},"1200":{"slidesPerView":5},"1400":{"slidesPerView":6}}}'> <div class="swiper-wrapper"> <?php while ($row = mysqli_fetch_assoc($result)) { ?> <div class="swiper-slide"> <div class="category-card" data-cue="slideInUp"> <div class="box-img"> <a href="shop.php?category=<?= $row['category_id']; ?>"> <img src="slgadmintoys/uploads/<?= $row['category_image']; ?>" alt="<?= $row['category_name']; ?>" /> </a> </div> <h3 class="box-title"> <a href="shop.php?category=<?= $row['category_id']; ?>"><?= $row['category_name']; ?></a> </h3> </div> </div> <?php } ?> </div> </div> <button data-slider-prev="#categorySlider1" class="slider-arrow slider-prev"><i class="far fa-arrow-left"></i></button> <button data-slider-next="#categorySlider1" class="slider-arrow slider-next"><i class="far fa-arrow-right"></i></button> </div> </div> </section> <!-- shop by category --> <!-- Top Rating Items --> <?php $query = "SELECT id, name, price, image_1 FROM slgtoys_products LIMIT 6"; // Limit to 6 products for demonstration $productResult = mysqli_query($conn, $query); if (!$productResult) { die("Query failed: " . mysqli_error($conn)); } ?> <section class="mt-60 mb-60"> <div class="container"> <div class="row gy-30 justify-content-center"> <div class="col-xxl-9 col-xl-7"> <div class="product-list-wrap1 bg-white"> <div class="row justify-content-between align-items-center"> <div class="col-md-auto"> <div class="title-area mb-30 text-center" data-cue="slideInUp"> <h3 class="sec-title">Top Rating Items</h3> </div> </div> <div class="col-md-auto"> <div class="sec-btn mb-30" data-cue="slideInUp"> <a href="shop.php" class="ot-btn style7">View More<i class="fas fa-arrow-right ms-2"></i></a> </div> </div> </div> <div class="row gy-30 justify-content-xxl-start justify-content-center"> <?php while ($row = mysqli_fetch_assoc($productResult)) { ?> <div class="col-xxl-6 col-xl-12 col-lg-6"> <div class="ot-product list-view style-border" data-cue="slideInUp"> <div class="product-img"> <img src="slgadmintoys/<?= $row['image_1'] ?>" alt="<?= htmlspecialchars($row['name']) ?>" /> </div> <div class="product-content"> <h3 class="box-title"> <a href="product-details.php?id=<?= $row['id'] ?>"><?= htmlspecialchars($row['name']) ?></a> </h3> <span class="price">Rs. <?= number_format($row['price'], 2) ?></span> </div> <div class="product-action-wrap align-self-center"> <button class="ot-btn style7 add-to-cart" data-product-id="<?php echo $row['id']; ?>"> <i class="fa-light fa-basket-shopping me-1"></i> Add To Cart </button> </div> </div> </div> <?php } ?> </div> </div> </div> <div class="col-xxl-3 col-xl-5 col-lg-7"> <div class="ad-card2"> <div class="card-content"> <h4 class="box-title">Best Toys for Kids <br> Starting</h4> <p class="card-price">Rs. 999 <del> Rs. 1999</del></p> <div class="btn-wrap"> <a href="shop.php" class="ot-btn">Shop Now<i class="fas fa-arrow-right ms-2"></i></a> </div> </div> <img class="w-100" src="assets/img/normal/ad1-2.jpg" alt="img" /> </div> </div> </div> </div> </section> <!-- Top Rating Items --> <!-- shop by age --> <?php // Fetch unique age categories from the database $ageQuery = "SELECT DISTINCT age_category FROM slgtoys_products"; $ageResult = mysqli_query($conn, $ageQuery); // Store age categories in an array $ageCategories = []; while ($row = mysqli_fetch_assoc($ageResult)) { $ageCategories[] = $row['age_category']; } ?> <section class="space-bottom overflow-hidden"> <div class="container"> <div class="row justify-content-center"> <div class="col-xl-4 col-lg-6 col-md-8"> <div class="title-area text-center"> <h2 class="sec-title" data-cue="slideInUp">Shop By Age</h2> <p class="sec-text" data-cue="slideInUp" data-delay="100">Find the perfect toys for every age group, carefully curated to match each stage of childhood at Siliguri Toys.</p> </div> </div> </div> <div class="slider-area"> <div class="swiper ot-slider" id="categorySlider2" data-slider-options='{"breakpoints":{"0":{"slidesPerView":3},"400":{"slidesPerView":"2"},"768":{"slidesPerView":"3"},"992":{"slidesPerView":"4"},"1200":{"slidesPerView":"5"}}}'> <div class="swiper-wrapper"> <?php // Define an array of colors for the age categories $colors = ["#C9E5EC", "#E5C3EB", "#BEEAB8", "#FFBBBB", "#EEE78D"]; $borderColors = ["#E6F5F9", "#F6E6F9", "#E0FBDD", "#FFDCDC", "#FFFABD"]; // Loop through age categories and generate cards foreach ($ageCategories as $index => $ageCategory) { $color = $colors[$index % count($colors)]; // Cycle through colors $borderColor = $borderColors[$index % count($borderColors)]; // Cycle through border colors ?> <div class="swiper-slide"> <div class="category-card2" data-cue="slideInUp"> <a href="shop.php?age_category=<?php echo urlencode($ageCategory); ?>" class="box-img" data-theme-color="<?php echo $color; ?>"> <div class="box-img-border" data-theme-color="<?php echo $borderColor; ?>"></div> <img src="assets/img/category/category_card2_<?php echo ($index % 5) + 1; ?>.png" alt="Image" /> </a> <h3 class="box-title"><a href="shop.php?age_category=<?php echo urlencode($ageCategory); ?>"><?php echo htmlspecialchars($ageCategory); ?></a></h3> </div> </div> <?php } ?> </div> </div> <button data-slider-prev="#categorySlider2" class="slider-arrow slider-prev"><i class="far fa-arrow-left"></i></button> <button data-slider-next="#categorySlider2" class="slider-arrow slider-next"><i class="far fa-arrow-right"></i></button> </div> </div> </section> <!-- shop by age --> <!-- Banner --> <section class="mt-60 mb-60"> <div class="container z-index-common"> <div class="cta-box position-relative" data-bg-src="assets/img/bg/cta_bg_2_1.png"> <div class="body-particle" id="cta-particle"></div> <div class="row"> <div class="col-xl-6"> <div class="box-content text-xl-start text-center"> <div class="title-area mb-30" data-cue="slideInUp"> <h2 class="sec-title text-white"> Get 45% discount in all of<br class="d-xxl-block d-none" /> Our super Toys </h2> </div> <a href="shop.php" class="ot-btn style-white" data-cue="slideInUp" data-delay="100">Shop Now<i class="fas fa-arrow-right ms-2"></i></a> </div> </div> <div class="col-xl-6 align-self-end"> <div class="cta-thumb2-1 text-xl-end text-center" data-cue="slideInUp" data-delay="100"><img src="assets/img/normal/cta-thumb2-1.png" alt="img" /></div> </div> </div> </div> </div> </section> <!-- Banner --> <!-- brands --> <div class="space-bottom mt-60 mb-60"> <div class="container ot-container"> <div class="row justify-content-center"> <div class="col-xl-4 col-lg-6 col-md-8"> <div class="title-area text-center"> <h2 class="sec-title" data-cue="slideInUp">We Deal In</h2> <p class="sec-text" data-cue="slideInUp" data-delay="100">We Deal In high-quality, safe, and engaging toys that inspire creativity and fun for kids of all ages at Siliguri Toys.</p> </div> </div> </div> <div class="swiper ot-slider" id="blogSlider1" data-slider-options='{"breakpoints":{"0":{"slidesPerView":4},"576":{"slidesPerView":"2"},"768":{"slidesPerView":"3"},"992":{"slidesPerView":"4"},"1200":{"slidesPerView":"5"},"1400":{"slidesPerView":"7"}}}'> <div class="swiper-wrapper"> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_1.png" alt="Brand Logo" /></a> </div> </div> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_2.png" alt="Brand Logo" /></a> </div> </div> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_3.png" alt="Brand Logo" /></a> </div> </div> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_4.png" alt="Brand Logo" /></a> </div> </div> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_5.png" alt="Brand Logo" /></a> </div> </div> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_6.png" alt="Brand Logo" /></a> </div> </div> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_7.png" alt="Brand Logo" /></a> </div> </div> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_1.png" alt="Brand Logo" /></a> </div> </div> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_2.png" alt="Brand Logo" /></a> </div> </div> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_3.png" alt="Brand Logo" /></a> </div> </div> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_4.png" alt="Brand Logo" /></a> </div> </div> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_5.png" alt="Brand Logo" /></a> </div> </div> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_6.png" alt="Brand Logo" /></a> </div> </div> <div class="swiper-slide"> <div class="brand-card" data-cue="slideInUp"> <a target="_blank" href="#"><img src="assets/img/brand/brand_1_7.png" alt="Brand Logo" /></a> </div> </div> </div> </div> </div> </div> <!-- brands --> <?php include 'footer.php' ?> <script> var isLoggedIn = <?php echo ($user_id > 0) ? 'true' : 'false'; ?>; $(document).ready(function() { // Wishlist Button Click $(".wishlist-btn").click(function() { if (!isLoggedIn) { alert("You must login first!"); return; } var button = $(this); var productId = button.data("product-id"); $.ajax({ url: "wishlist_handler.php", method: "POST", data: { product_id: productId, csrf_token: "<?php echo $_SESSION['csrf_token']; ?>" }, success: function(response) { if (response == "added") { button.html('<i class="fa fa-heart"></i>'); } else { button.html('<i class="fa fa-heart-o"></i>'); } }, error: function(xhr, status, error) { alert("An error occurred: " + error); } }); }); // Add to Cart Button Click $(".add-to-cart").click(function() { if (!isLoggedIn) { alert("You must login first!"); return; } var button = $(this); var productId = button.data("product-id"); $.ajax({ url: "cart_handler.php", method: "POST", data: { product_id: productId, action: "add", csrf_token: "<?php echo $_SESSION['csrf_token']; ?>" }, success: function(response) { alert("Product added to cart!"); }, error: function(xhr, status, error) { alert("An error occurred: " + error); } }); }); }); </script> </body> </html>