D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
ashwika.encodersunlimited.com
/
Filename :
product-details.php
back
Copy
<?php require("ashadminwika/config.php"); // Initialize variables $product = null; $error_message = ''; $success_message = ''; // Check if form is submitted if ($_SERVER["REQUEST_METHOD"] == "POST") { // Get POST data $product_id = intval($_POST['id']); $customer_name = mysqli_real_escape_string($conn, $_POST['customer_name']); $customer_email = mysqli_real_escape_string($conn, $_POST['customer_email']); $customer_phone = mysqli_real_escape_string($conn, $_POST['customer_phone']); $message = mysqli_real_escape_string($conn, $_POST['message']); $quantity = intval($_POST['quantity']); // Query to insert data into product_query table $query = "INSERT INTO product_query (product_id, customer_name, customer_email, customer_phone, message, quantity, created_at) VALUES ('$product_id', '$customer_name', '$customer_email', '$customer_phone', '$message', '$quantity', NOW())"; // Execute query if (mysqli_query($conn, $query)) { $success_message = "Quote request submitted successfully."; } else { $error_message = "Error: " . mysqli_error($conn); } } // Get the product ID from the URL $id = isset($_GET['id']) ? intval($_GET['id']) : 0; if ($id > 0) { // Query to fetch the product based on the ID $query = "SELECT p.*, c.category_name, s.subcategory_name FROM products p INNER JOIN product_category c ON p.category = c.id INNER JOIN product_subcategory s ON p.subcategory = s.id WHERE p.id = '$id'"; $result = mysqli_query($conn, $query); // Check if the query was successful and returned a result if ($result && mysqli_num_rows($result) > 0) { $product = mysqli_fetch_assoc($result); } else { $error_message = "Product not found."; } } else { $error_message = "Invalid product ID."; } mysqli_close($conn); ?> <!doctype html> <html class="no-js" lang="zxx"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title><?php echo htmlspecialchars($product ? $product['name'] : 'Product Details'); ?> - Product Details</title> <?php require("style.php"); ?> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/5.1.3/css/bootstrap.min.css" rel="stylesheet"> <style> /* Modal Styling */ /* Modal Styling */ .modal-content { border-radius: 12px; border: none; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); background-color: #ffffff; } .modal-header { border-bottom: none; background-color: #007bff; color: #ffffff; padding: 15px; border-radius: 12px 12px 0 0; } .modal-title { font-size: 20px; font-weight: 700; } .close { font-size: 1.75rem; color: #ffffff; } .modal-body { padding: 20px; } .modal-footer { border-top: none; background-color: #f8f9fa; padding: 15px; border-radius: 0 0 12px 12px; } .modal-footer .btn { border-radius: 4px; font-weight: 600; transition: background-color 0.3s, border-color 0.3s; } .btn-primary { background-color: #28a745; border-color: #28a745; padding: 7px 9px; color: white; } .btn-primary:hover { background-color: #218838; border-color: #1e7e34; } .btn-secondary { background-color: #6c757d; border-color: #6c757d; } .btn-secondary:hover { background-color: #5a6268; border-color: #545b62; } .form-control { border-radius: 6px; border: 1px solid #ced4da; box-shadow: none; transition: border-color 0.3s, box-shadow 0.3s; } .form-control:focus { border-color: #007bff; box-shadow: 0 0 0 0.2rem rgba(38, 143, 255, 0.25); } label { font-weight: 500; } textarea { resize: vertical; } .modal-dialog { max-width: 500px; margin: 30px auto; } </style> </head> <body> <?php require("header.php"); ?> <main> <div class="breadcrumb-area"> <div class="container"> <div class="row"> <div class="col-12"> <div class="breadcrumb-wrap"> <nav aria-label="breadcrumb"> <ul class="breadcrumb"> <li class="breadcrumb-item"><a href="index.html"><i class="fa fa-home"></i></a></li> <li class="breadcrumb-item"><a href="shop.html">Get Details</a></li> <li class="breadcrumb-item active" aria-current="page">Product Details</li> </ul> </nav> </div> </div> </div> </div> </div> <div class="shop-main-wrapper section-padding pb-0"> <div class="container"> <div class="row"> <?php if ($product): ?> <div class="col-lg-12 order-1 order-lg-2"> <div class="product-details-inner"> <div class="row"> <div class="col-lg-5"> <div class="product-large-slider"> <div class="pro-large-img img-zoom"> <img src="ashadminwika/uploads/<?php echo htmlspecialchars($product['image']); ?>" alt="product-details" /> </div> </div> </div> <div class="col-lg-7"> <div class="product-details-des"> <h3 class="product-name"><?php echo htmlspecialchars($product['name']); ?></h3> <p class="pro-desc"><?php echo htmlspecialchars($product['short_desc']); ?></p> <div class="quantity-cart-box d-flex align-items-center"> <h6 class="option-title">Qty:</h6> <div class="quantity"> <div class="pro-qty"><input type="text" value="1"></div> </div> <div class="action_link"> <a class="btn btn-cart2" data-bs-toggle="modal" data-bs-target="#quoteModal">Get Quote</a> </div> </div> <div class="pro-size"> <h6 class="option-title">Size:</h6> <select class="nice-select"> <?php $sizes = explode(',', $product['size']); foreach ($sizes as $size) { echo '<option>' . htmlspecialchars($size) . '</option>'; } ?> </select> </div> </div> </div> </div> </div> <div class="product-details-reviews section-padding pb-0"> <div class="row"> <div class="col-lg-12"> <div class="product-review-info"> <ul class="nav review-tab"> <li><a class="active" data-bs-toggle="tab" href="#tab_one">Description</a></li> <li><a data-bs-toggle="tab" href="#tab_two">Information</a></li> </ul> <div class="tab-content reviews-tab"> <div class="tab-pane fade show active" id="tab_one"> <div class="tab-one"> <p><?php echo htmlspecialchars($product['description']); ?></p> </div> </div> <div class="tab-pane fade" id="tab_two"> <table class="table table-bordered"> <tbody> <tr> <td>Size</td> <td><?php echo htmlspecialchars($product['size']); ?></td> </tr> <tr> <td>Certification</td> <td><?php echo htmlspecialchars($product['certification']); ?></td> </tr> <tr> <td>Purity</td> <td><?php echo htmlspecialchars($product['purity']); ?></td> </tr> </tbody> </table> </div> </div> </div> </div> </div> </div> </div> <?php else: ?> <div class="col-lg-12"> <p><?php echo htmlspecialchars($error_message); ?></p> </div> <?php endif; ?> </div> </div> </div> </main> <?php require("footer.php"); ?> <!-- Modal --> <div class="modal fade" id="quoteModal" tabindex="-1" aria-labelledby="quoteModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="quoteModalLabel">Get a Quote</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <form action="#" method="post" class="review-form"> <div class="form-group"> <label for="customer_name">Your Name</label> <input type="text" id="customer_name" name="customer_name" class="form-control" required> </div> <div class="form-group"> <label for="customer_email">Your Email</label> <input type="email" id="customer_email" name="customer_email" class="form-control" required> </div> <div class="form-group"> <label for="customer_phone">Your Phone</label> <input type="text" id="customer_phone" name="customer_phone" class="form-control" required> </div> <div class="form-group"> <label for="message">Your Message</label> <textarea id="message" name="message" class="form-control" required></textarea> </div> <div class="form-group"> <label for="quantity">Quantity</label> <input type="number" id="quantity" name="quantity" class="form-control" value="1" required> </div> <input type="hidden" name="id" value="<?php echo htmlspecialchars($id); ?>"> <button type="submit" class="btn btn-primary btns">Submit Quote</button> </form> <?php if ($success_message): ?> <div class="alert alert-success mt-3"><?php echo htmlspecialchars($success_message); ?></div> <?php endif; ?> <?php if ($error_message): ?> <div class="alert alert-danger mt-3"><?php echo htmlspecialchars($error_message); ?></div> <?php endif; ?> </div> </div> </div> </div> <!-- JavaScript Libraries --> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script> <script src="assets/js/main.js"></script> </body> </html>