<?php

if (isset($_POST['submit'])) {

    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $othername = $_POST['othername'];
    $academic = $_POST['academic'];
    $nationality = $_POST['nationality'];
    $institution = $_POST['institution'];
    $address = $_POST['address'];
    $postalCode = $_POST['postalCode'];
    $townCity = $_POST['townCity'];
    $country = $_POST['country'];
    $telephone = $_POST['telephone'];
    $email = $_POST['email'];
    $nationalID = $_POST['nationalID'];


    $title = $_POST['subject'];
    $message = $_POST['message'];


    $to = 'mannehills@gmail.com';
    $subject = 'Application Form';

    $message = "
        First Name: ".$firstname."  
        Last Name:".$lastname."   
        Other Name: ".$othername."  
        Highest Academic/Professional Qualification: ".$academic."   
        Nationality: ".$nationality."
        Institution/Company: ".$institution"
        Address: ".$address."
        Postal Code: ".$postalCode."
        Town/City: ".$townCity."
        Country: ".$country."
        Telephone: ".$telephone."
        Email: ".$email."   
        National ID/Passport: ".$nationality."

        "; 
    
    
    $from = $email;

    // if($email == "leeann2poulsen@forum.dk" || $email == "linabug@gmail.com" || $name == "HenryTigue"){

    // }else{  
        // Sending email
    if (mail($to, $subject, $message)) {
        echo '
            <script>
            window.location.href="contact?message_sent";
            </script>
            ';
        } else {
        echo '
            <script>
            window.location.href="contact?message_not_sent";
            </script>
            ';
        }
    // }
}

?>