<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $fname = $_POST['fname'];
    $lname = $_POST['lname'];
    $tel_no = $_POST['tel_no'];
    $email = $_POST['email'];
    $address_1 = $_POST['address_1'];
    $address_2 = $_POST['address_2'];
    $city = $_POST['city'];
    $postal_code = $_POST['postal_code'];
    $country = $_POST['country'];
    $del_method = $_POST['del_method'];
    $s_msg = $_POST['s_msg'];

    $to = "keshnijay@gmail.com"; // Replace with your email address
    $subject = "New Order from $fname $lname";
    $headers = "From: $email" . "\r\n" .
               "Reply-To: $email" . "\r\n" .
               "Content-Type: text/html; charset=UTF-8" . "\r\n";

    $message = "
    <html>
    <head>
        <title>New Order</title>
    </head>
    <body>
        <h2>Order Details</h2>
        <p><strong>First Name:</strong> $fname</p>
        <p><strong>Last Name:</strong> $lname</p>
        <p><strong>Contact No:</strong> $tel_no</p>
        <p><strong>Email:</strong> $email</p>
        <p><strong>Address Line 1:</strong> $address_1</p>
        <p><strong>Address Line 2:</strong> $address_2</p>
        <p><strong>City:</strong> $city</p>
        <p><strong>Postal Code:</strong> $postal_code</p>
        <p><strong>Country:</strong> $country</p>
        <p><strong>Delivery Method:</strong> $del_method</p>
        <p><strong>Special Message:</strong> $s_msg</p>
    </body>
    </html>
    ";

    if (mail($to, $subject, $message, $headers)) {
        echo "Email sent successfully!";
    } else {
        echo "Failed to send email.";
    }
}
?>
