<!DOCTYPE html>
<html lang="en">

<head>
    <?php include("include/meta.php");?>
    <?php include("include/css.php");?>
</head>
<style>
.contact-content-form {
    color: #eb9602;
    font-size: 17px;
    padding: 56px 30px;
}

.contact-content-form i {
    color: #bd252a;
}

.contact-img {
    background: #f1dcff38;
}
</style>

<body>

    <!-- header area -->
    <?php include("include/header.php");?>
    <!-- header area end -->


    <main class="main">

        <!-- breadcrumb -->
        <?php
            $banner_sql = "SELECT * FROM data_table WHERE up_by = $x && page_type = 'slider' && recycle = '1' ORDER BY id DESC";
            $banner_run = mysqli_query($con, $banner_sql);
            if ($banner_row = mysqli_fetch_assoc($banner_run)) {
            ?>
        <div class="site-breadcrumb" style="background: url(./login/upload/<?php echo $banner_row['image_one']?>)">
            <div class="container">
                <h2 class="breadcrumb-title">Contact Us</h2>
                <ul class="breadcrumb-menu">
                    <li><a href="index.html">Home</a></li>
                    <li class="active">Contact Us</li>
                </ul>
            </div>
        </div>
        <?php } ?>
        <!-- breadcrumb end -->


        <!-- contact area -->
        <div class="contact-area py-120">
            <div class="container">
                <div class="contact-content">
                    <div class="row">
                        <div class="col-md-4">
                            <div class="contact-info">
                                <div class="contact-info-icon">
                                    <i class="fal fa-map-location-dot"></i>
                                </div>
                                <div class="contact-info-content">
                                    <h5>Office Address</h5>
                                    <p style="font-size: 13px;"><?php 
                                        $address = [];
                                        if (!empty($user_rows['uaddress1'])) {
                                            $address[] = $user_rows['uaddress1'];
                                        }
                                        if (!empty($user_rows['uaddress2'])) {
                                            $address[] = $user_rows['uaddress2'];
                                        }
                                        echo implode(', ', $address);
                                    ?></p>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="contact-info">
                                <div class="contact-info-icon">
                                    <i class="fal fa-phone-volume"></i>
                                </div>
                                <div class="contact-info-content">
                                    <h5>Call Us</h5>
                                    <?php if(!empty($user_rows['uphone'])): ?>
                                    <p>
                                        <a href="tel:<?php echo $user_rows['uphone']; ?>">
                                            <?php echo $user_rows['uphone']; ?>
                                        </a>
                                        <span style="color:#ddd;">or</span>
                                        <?php endif; ?>

                                        <?php if(!empty($user_rows['uothcontact'])): ?>
                                        <a href="tel:<?php echo $user_rows['uothcontact']; ?>">
                                            <?php echo $user_rows['uothcontact']; ?>
                                        </a>
                                    </p>
                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="contact-info">
                                <div class="contact-info-icon">
                                    <i class="fal fa-envelopes"></i>
                                </div>
                                <div class="contact-info-content">
                                    <h5>Email Us</h5>
                                    <p><?php echo $user_rows['umail']; ?></p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="contact-wrapper">
                    <div class="row align-items-center  ">
                        <div class="col-lg-5">
                            <div class="contact-img">
                                <div class="contact-content-form">
                                    <p class="mb-1"><i class="fal fa-pencil"></i> &nbsp; At Macaw Public School,
                                        education
                                        gives every child the courage to dream and the
                                        strength
                                        to achieve.</p>
                                    <p class="mb-1"><i class="fal fa-pencil"></i> &nbsp; We build minds that
                                        reason,
                                        hearts that care, and spirits that rise — ready to
                                        fly
                                        high
                                        in every field of life.</p>
                                    <p class="mb-1"><i class="fal fa-pencil"></i> &nbsp; Have questions or want to
                                        visit?
                                        We’re here to help! Reach out to us anytime—we’d
                                        love to
                                        welcome you to the Macaow family and guide you through the admission process.
                                    </p>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-7 align-self-center">
                            <div class="contact-form">
                                <div class="contact-form-header">
                                    <h2>Get In Touch</h2>
                                </div>
                                <form method="post" action="" id="contact-form">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <input type="text" name="name" class="form-control"
                                                    placeholder="Your Name">
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <input type="number" name="contact" class="form-control"
                                                    placeholder="Mobile Number">
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <input type="email" name="email" class="form-control"
                                                    placeholder="Email Address">
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <input type="text" class="form-control" name="subject"
                                                    placeholder="Your Subject" required>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <textarea name="message" cols="30" rows="2" class="form-control"
                                            placeholder="Write Your Message"></textarea>
                                    </div>
                                    <button type="submit" class="theme-btn" name="submit">Send
                                        Message <i class="far fa-paper-plane"></i></button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- end contact area -->

        <!-- map -->
        <?php if(!empty($user_rows['umap'])){?>
        <div class="contact-map">
            <iframe src="<?php echo htmlspecialchars($user_rows['umap']); ?>" style="border:0;" allowfullscreen=""
                loading="lazy"></iframe>
        </div>
        <?php }?>

    </main>



    <!-- footer area -->
    <?php include("include/footer.php");?>
    <!-- footer area end -->

    <!-- js -->
    <?php include("include/js.php");?>

</body>

</html>


<?php
if (isset($_POST['submit'])) {
    $conname    = mysqli_real_escape_string($con, strip_tags($_POST['name']));
    $conno      = mysqli_real_escape_string($con, strip_tags($_POST['contact']));
    $conemail   = mysqli_real_escape_string($con, strip_tags($_POST['email']));
    $conmessage = mysqli_real_escape_string($con, strip_tags($_POST['message']));
    $consubject = mysqli_real_escape_string($con, strip_tags($_POST['subject'])); 

    $conref = $x;
    $concreatedon = date("j F, Y, g:i a");

    $contact_sql = "INSERT INTO contact 
        (conname, conno, conmessage, conref, concreatedon, consubject, conemail) 
        VALUES 
        ('$conname', '$conno', '$conmessage', '$conref', '$concreatedon', '$consubject', '$conemail')";

    // Mail setup
    $to = $email_id;
    $subject = "Contact Details Of Customer";
    $message = "Name: $conname\n";
    $message .= "Phone Number: $conno\n";
    $message .= "Email Id: $conemail\n";
    $message .= "Course Selected: $consubject\n";
    $message .= "Message: $conmessage\n";

    $headers = "From: noreply@yourdomain.com\r\n";

    if (mysqli_query($con, $contact_sql)) {
        mail($to, $subject, $message, $headers);
        ?>
<script>
alert("Details Sent Successfully");
window.location = "contact.php";
</script>
<?php
    } else {
        ?>
<script>
alert("Something's Wrong");
window.location = "contact.php";
</script>
<?php
    }
}
?>