<?php 
if(isset($_POST["submit"])){
    $email = $_POST['email'];
    $name = $_POST['name'];
    $body = " Dear $name,<br><br> Thank you for contacting Us at www.travelsspeed.com <br><br><a href='travelsspeed.com'>Travel Now</a><br><br> Best Regards,";
    $subject = "Thank You for Contacting Us";

    $headers = array(
        'Authorization: Bearer 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',
        'Content-Type: application/json'
    );

    $data = array(
        "personalizations" => array(
            array(
                "to" => array(
                    array(
                        "email" => $email,
                        "name" => $name
                    )
                )
            )
        ),
        "from" => array(
            "email" => "info@travelsspeed.com"
        ),
        "subject" => $subject,
        "content" => array(
            array(
                "type" => "text/html",
                "value" => $body
            )
        )
    );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://api.sendgrid.com/v3/mail/send");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($ch);
    curl_close($ch);

    if (empty($response)){
        echo "Done";
    } else {
        echo $response;
    }
}
?>
<!DOCTYPE html>
<html lang="en-US">
<?php include "pages/header.php"; ?>

<div id="page-title" class="text-grey background-overlay background-img-dark" style="background-image: url('images/page-title-9.jpg');">
    <div class="text-center">
        <div class="container padding-tb-120px z-index-2 position-relative">
            <h1 class="font-weight-400 text-uppercase">Contact Us</h1>
        </div>
    </div>
</div>

<section class="padding-tb-50px">
    <div class="container">
        <div class="row">
            <div class="col-lg-6 mb-4">
                <form action="" method="post">
                    <div class="form-row">
                        <div class="form-group col-md-6">
                            <label for="inputName">Full Name</label>
                            <input type="text" class="form-control" name="name" placeholder="Name">
                        </div>
                        <div class="form-group col-md-6">
                            <label for="inputEmail4">Email</label>
                            <input type="email" class="form-control" name="email" placeholder="Email">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="Address">Address</label>
                        <input type="text" class="form-control" id="Address" name="address" placeholder="26 Aba road, Port Harcourt">
                    </div>
                    <div class="form-group">
                        <label for="messageTextarea">Message</label>
                        <textarea class="form-control" id="messageTextarea" name="message" rows="4"></textarea>
                    </div>
                    <button type="submit" name="submit" class="btn btn-primary">Submit</button>
                </form>
            </div>
            <div class="col-lg-6">
                <p>We are available 24/7. Kindly contact us through the details below.</p>
                <h6>Phone :</h6>
                <span class="d-block"><i class="fa fa-phone text-main-color margin-right-10px" aria-hidden="true"></i> 08074406431</span>
                <span class="d-block"><i class="fa fa-mobile text-main-color margin-right-10px" aria-hidden="true"></i> 08074406493</span>
                <h6 class="margin-top-20px">Address :</h6>
                <span class="d-block"><i class="fa fa-map text-main-color margin-right-10px" aria-hidden="true"></i> 26 Aba road, Port Harcourt</span>
                <h6 class="margin-top-20px">Email :</h6>
                <span class="d-block"><i class="fa fa-envelope-open text-main-color margin-right-10px" aria-hidden="true"></i> info@travelsspeed.com</span>
            </div>
        </div>
    </div>
</section>

<div class="map-distributors-in">
    <div id="map-distributors">
        <div class="mapouter"><div class="gmap_canvas"><iframe width="100%" height="400" id="gmap_canvas" src="https://maps.google.com/maps?q=26%20aba%20road&t=&z=15&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe></div><style>.mapouter{position:relative;text-align:right;height:400px;width:100%;}.gmap_canvas {overflow:hidden;background:none!important;height:400px;width:100%;}</style></div>
    </div>
</div>

<?php include "pages/footer.php"; ?>

<script type="text/javascript" src="//<?= $_SERVER['HTTP_HOST']; ?>/js/custom.js"></script>
<script src="//<?= $_SERVER['HTTP_HOST']; ?>/js/owl.carousel.min.js"></script>
<script type="text/javascript" src="//<?= $_SERVER['HTTP_HOST']; ?>/js/jquery-ui.js"></script>
<script type="text/javascript" src="//<?= $_SERVER['HTTP_HOST']; ?>/js/popper.min.js"></script>
<script type="text/javascript" src="//<?= $_SERVER['HTTP_HOST']; ?>/js/bootstrap.min.js"></script>
</body>
</html>
