📁 File Manager
Editing:
/home/wedigitalindia/public_html/mvskpowdercoating.com/contact.php
<?php /* ========================================================= DATABASE ========================================================= */ require_once __DIR__ . "/admin/inc/config.php"; require_once __DIR__ . "/data/site.php"; require_once __DIR__ . "/data/contact.php"; /* ========================================================= CONTACT FORM SUBMISSION ========================================================= */ $contact_success = false; $contact_error = ""; if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["submit_contact"])) { $name = trim($_POST["name"] ?? ""); $email = trim($_POST["email"] ?? ""); $phone = trim($_POST["phone"] ?? ""); $product_name = trim($_POST["product"] ?? ""); $message = trim($_POST["message"] ?? ""); /* ===================================================== VALIDATION ===================================================== */ if ( $name === "" || $email === "" || $phone === "" || $product_name === "" || $message === "" ) { $contact_error = "Please fill in all required fields."; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $contact_error = "Please enter a valid email address."; } else { try { /* ================================================= INSERT INTO DATABASE ================================================= */ $stmt = $pdo->prepare(" INSERT INTO tbl_customer ( name, email, phone, product_name, message, cust_status ) VALUES ( :name, :email, :phone, :product_name, :message, 1 ) "); $stmt->execute([ ":name" => $name, ":email" => $email, ":phone" => $phone, ":product_name" => $product_name, ":message" => $message ]); /* ================================================= SUCCESS ================================================= */ $contact_success = true; /* Clear submitted values */ $_POST = []; } catch (PDOException $e) { $contact_error = "Unable to submit your message. Please try again."; /* FOR TESTING ONLY: $contact_error = $e->getMessage(); */ } } } /* ========================================================= HEADER ========================================================= */ require_once __DIR__ . "/includes/header.php"; ?> <!-- ======================================================= CONTACT HERO ======================================================= --> <section class="contact-hero" style="background-image:url('<?= $site['base_url'] ?><?= htmlspecialchars($contact_page["banner_image"], ENT_QUOTES, "UTF-8") ?>');"> <div class="contact-hero-overlay"></div> <div class="container-fluid px-lg-5"> <div class="contact-hero-content"> <span class="contact-hero-eyebrow"> <?= htmlspecialchars( $contact_page["eyebrow"], ENT_QUOTES, "UTF-8" ) ?> </span> <h1> Contact Us </h1> <div class="contact-breadcrumb"> <a href="index.php"> Home </a> <i class="bi bi-chevron-right"></i> <strong> Contact Us </strong> </div> </div> </div> </section> <!-- ======================================================= CONTACT SECTION ======================================================= --> <section class="contact-section"> <div class="container-fluid px-lg-5"> <!-- ================================================= SUCCESS ALERT ================================================== --> <?php if ($contact_success): ?> <div class="contact-alert contact-alert-success" id="contactAlert"> <div class="contact-alert-icon"> <i class="bi bi-check-lg"></i> </div> <div class="contact-alert-content"> <strong> Message Sent Successfully </strong> <span> Thank you for contacting us. Our team will get back to you shortly. </span> </div> <button type="button" class="contact-alert-close" onclick="closeContactAlert()"> <i class="bi bi-x"></i> </button> </div> <?php endif; ?> <!-- ================================================= ERROR ALERT ================================================== --> <?php if (!empty($contact_error)): ?> <div class="contact-alert contact-alert-error" id="contactAlert"> <div class="contact-alert-icon"> <i class="bi bi-exclamation-lg"></i> </div> <div class="contact-alert-content"> <strong> Unable to Send Message </strong> <span> <?= htmlspecialchars( $contact_error, ENT_QUOTES, "UTF-8" ) ?> </span> </div> <button type="button" class="contact-alert-close" onclick="closeContactAlert()"> <i class="bi bi-x"></i> </button> </div> <?php endif; ?> <!-- ================================================= TOP GRID ================================================== --> <div class="contact-top-grid"> <!-- ================================================= CONTACT INFORMATION ================================================== --> <div class="contact-information"> <div class="contact-section-heading"> <h2> Contact Information </h2> </div> <div class="contact-details"> <?php foreach ($contact_details as $detail): ?> <?php if (empty($detail["value"])) continue; ?> <div class="contact-detail"> <div class="contact-detail-icon"> <i class="bi <?= htmlspecialchars( $detail["icon"], ENT_QUOTES, "UTF-8" ) ?>"></i> </div> <div class="contact-detail-content"> <h3> <?= htmlspecialchars( $detail["title"], ENT_QUOTES, "UTF-8" ) ?> </h3> <?php if (is_array($detail["value"])): ?> <?php foreach ($detail["value"] as $value): ?> <?php if ($detail["title"] === "Phone"): ?> <a href="tel:<?= htmlspecialchars( $value, ENT_QUOTES, "UTF-8" ) ?>"> <?= htmlspecialchars( $value, ENT_QUOTES, "UTF-8" ) ?> </a> <?php elseif ($detail["title"] === "Email"): ?> <a href="mailto:<?= htmlspecialchars( $value, ENT_QUOTES, "UTF-8" ) ?>"> <?= htmlspecialchars( $value, ENT_QUOTES, "UTF-8" ) ?> </a> <?php else: ?> <p> <?= htmlspecialchars( $value, ENT_QUOTES, "UTF-8" ) ?> </p> <?php endif; ?> <?php endforeach; ?> <?php else: ?> <p> <?= htmlspecialchars( $detail["value"], ENT_QUOTES, "UTF-8" ) ?> </p> <?php endif; ?> </div> </div> <?php endforeach; ?> <!-- ================================================= BUSINESS HOURS ================================================== --> <div class="contact-detail"> <div class="contact-detail-icon"> <i class="bi bi-clock"></i> </div> <div class="contact-detail-content"> <h3> Business Hours </h3> <p> <strong> Mon - Sat </strong> 9:00 AM - 6:00 PM </p> </div> </div> </div> </div> <!-- ================================================= ENQUIRY FORM ================================================== --> <div class="contact-enquiry"> <div class="contact-section-heading"> <h2> Get In Touch </h2> </div> <!-- IMPORTANT: action="" means form submits to THIS SAME PAGE --> <form action="" method="post" class="contact-form" id="enquiry"> <div class="contact-form-fields"> <!-- NAME --> <div class="contact-form-field"> <input type="text" name="name" placeholder="Your Name*" value="<?= htmlspecialchars( $_POST["name"] ?? "", ENT_QUOTES, "UTF-8" ) ?>" required> </div> <!-- EMAIL --> <div class="contact-form-field"> <input type="email" name="email" placeholder="Your Email*" value="<?= htmlspecialchars( $_POST["email"] ?? "", ENT_QUOTES, "UTF-8" ) ?>" required> </div> <!-- PHONE --> <div class="contact-form-field"> <input type="tel" name="phone" placeholder="Phone*" value="<?= htmlspecialchars( $_POST["phone"] ?? "", ENT_QUOTES, "UTF-8" ) ?>" required> </div> <!-- PRODUCT --> <div class="contact-form-field"> <input type="text" name="product" placeholder="Product*" value="<?= htmlspecialchars( $_POST["product"] ?? "", ENT_QUOTES, "UTF-8" ) ?>" required> </div> <!-- MESSAGE --> <div class="contact-form-field"> <textarea name="message" placeholder="Your Message*" required><?= htmlspecialchars( $_POST["message"] ?? "", ENT_QUOTES, "UTF-8" ) ?></textarea> </div> </div> <div class="contact-form-bottom"> <div class="contact-form-bottom"> <!-- SUBMIT --> <button type="submit" name="submit_contact" value="1" class="contact-submit"> <span> Send Message </span> <i class="bi bi-arrow-right"></i> </button> </div> </div> </form> </div> </div> <!-- ================================================= MAP ================================================== --> <div class="contact-map-section"> <div class="contact-map"> <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3496.6682124569197!2d77.52290889999999!3d28.789154699999994!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x390cf45b780940c9%3A0x35c5006f4b56ba5a!2sNew%20Touch%20Technology%20(MVSK%20Industries%20LLP)!5e0!3m2!1sen!2sin!4v1788928735137!5m2!1sen!2sin" width="100%" height="100%" style="border:0" allowfullscreen="" loading="lazy" referrerpolicy="strict-origin-when-cross-origin"> </iframe> </div> </div> </div> </section> <!-- ======================================================= ALERT JAVASCRIPT ======================================================= --> <script> function closeContactAlert() { const alertBox = document.getElementById("contactAlert"); if (!alertBox) { return; } alertBox.style.opacity = "0"; alertBox.style.transform = "translateY(-10px)"; setTimeout(function() { alertBox.remove(); }, 300); } document.addEventListener("DOMContentLoaded", function() { const alertBox = document.getElementById("contactAlert"); if (alertBox) { setTimeout(function() { closeContactAlert(); }, 5000); } }); </script> <?php require_once __DIR__ . "/includes/footer.php"; ?>
Save
Cancel