<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {

    // Receive Form Data
    $name    = $_POST['name'];
    $email   = $_POST['email'];
    $phone   = $_POST['phone'];
    $message = $_POST['message'];

    // =======================================
    //      SEND EMAIL
    // =======================================

    $to = "info@rbvroyalsbiltmorevacation.com";
    $subject = "New Contact Form Query";

    $htmlMessage = "
        <h3>New Contact Form Submission</h3>
        <p><strong>Name:</strong> $name</p>
        <p><strong>Email:</strong> $email</p>
        <p><strong>Phone:</strong> $phone</p>
        <p><strong>Message:</strong> $message</p>
    ";

    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=UTF-8\r\n";
    $headers .= "From: Website Contact Form <no-reply@yourdomain.com>\r\n";

    mail($to, $subject, $htmlMessage, $headers);

    // =======================================
    //      SEND WHATSAPP MESSAGE
    // =======================================

    $whatsapp = "919911101669";

    $wa_text = urlencode(
        "New Website Query\n\n".
        "Name: $name\n".
        "Email: $email\n".
        "Phone: $phone\n".
        "Message: $message"
    );

    $wa_url = "https://wa.me/$whatsapp?text=$wa_text";

    // Redirect to WhatsApp
    echo "<script>window.location.href='$wa_url';</script>";
    exit();
}
?>
