<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Gather form data
    $organisation = $_POST["organisation"];
    $name = $_POST["name"];
    $email = $_POST["email"];
    $phone = $_POST["phone"];
    $address = $_POST["address"];
    $website = $_POST["website"];
    $mobile = $_POST["mobile"];

    // Construct message body
    $message = "Organisation: $organisation\n";
    $message .= "Name: $name\n";
    $message .= "Email: $email\n";
    $message .= "Phone Number: $phone\n";
    $message .= "Address: $address\n";
    $message .= "Website: $website\n";
    $message .= "Mobile: $mobile\n";

    // Process checkboxes
    $message .= "\nType of Entity:\n";
    $checkboxes = array("hobby", "homebased", "buisness", "nfp", "party");
    foreach ($checkboxes as $checkbox) {
        if (isset($_POST[$checkbox])) {
            $message .= "- " . ucfirst($checkbox) . "\n";
        }
    }

    // Process table checkboxes
    $message .= "\nBays and/or Area Required:\n";
    $tableCheckboxes = array("eh4m3m", "eh3m3m", "10m10m", "20m20m", "fsh3m3m", "food", "gs", "gsf", "trains", "other");
    foreach ($tableCheckboxes as $checkbox) {
        if (isset($_POST[$checkbox])) {
            $length = $_POST[$checkbox . "_length"];
            $depth = $_POST[$checkbox . "_depth"];
            $message .= "- " . ucfirst($checkbox) . ": Length: $length, Depth: $depth\n";
        }
    }

    // Email configuration
    $to = "sharris@wasps.net.au";  // Replace with your email address
    $subject = "New Form Submission";

    // Additional headers
    $headers = "From: $email";

    // Send email
    mail($to, $subject, $message, $headers);
}
?>
