<?php
include "db.php";

if ($_SERVER["REQUEST_METHOD"] == "POST") {

    if (isset($_POST['email']) && !empty($_POST['email'])) {

        $email = trim($_POST['email']);

        // Validate email
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            echo "Invalid email format";
            exit;
        }

        // Prepare statement (SECURE)
        $stmt = $conn->prepare("INSERT INTO subscribers (email) VALUES (?)");
        $stmt->bind_param("s", $email);

        if ($stmt->execute()) {
            echo "Subscribed successfully!";
        } else {
            echo "Error: " . $stmt->error;
        }

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

    } else {
        echo "Email is required";
    }
}
?>
<section class="footer-page-hero">

<div class="footer-page-hero-overlay"></div>

<div class="footer-page-hero-content">
    <h1 class="footer-page-hero-title">
        Let’s make energy exploration <br>
        and production cleaner, faster, <br>
        and smarter!
    </h1>

    <p class="footer-page-hero-sub">
        Contact us today for innovative equipment solutions <br>
        tailored to your operational needs!
    </p>
</div>

<!-- 🔥 ROTATING CTA -->
<div class="footer-page-cta">

    <img src="https:cdn.prod.website-files.com/6848312c31807741f8b0d49d/6848312c31807741f8b0d783_Text%20Rotate%20(2).svg"
    loading="lazy"
    alt="Get Started Today"
    class="image-text-rotate">

    <div class="footer-page-cta-arrow">↗</div>

</div>

</section>

<!-- ================= FOOTER ================= -->

<section class="footer-page-section">

<div class="footer-page-container">

    <div class="footer-page-logo">⚓ Well Gear Oil Tolls</div>

    <h2 class="footer-page-heading">
        Cleaner, Faster, Smarter <br>
        Equipment Solutions for the <br>
        Energy Future !
    </h2>

   <form action="" method="POST" class="footer-page-form">
    
    <input 
        type="email" 
        name="email" 
        placeholder="Enter your email" 
        class="footer-page-input" 
        required
    >

    <button 
        type="submit" 
        class="footer-page-btn"
    >
        SUBSCRIBE
    </button>

</form>

    <div class="footer-page-links">
        <a href="#">HOME</a>
        <a href="#">PRODUCTS</a>
        <a href="#">SERVICES</a>
        <a href="#">ABOUT US</a>
        <a href="#">R & D</a>
        <a href="#">CONTACT US</a>
    </div>

    <div class="footer-page-copy">
        © Copyright https://wellgearoiltools.com/
    </div>

</div>

</section>
 <script src="https://fontawesome.com" crossorigin="anonymous"></script>
<script src="https:cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>
<script src="../js/script.js"></script>
<script src="js/script.js"></script>

</body>
</html>