<?php
if(isset($_POST['contactFrmSubmit']) && !empty($_POST['firstname']) && !empty($_POST['lastname']) && (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) && !empty($_POST['apt']) && !empty($_POST['address']) && !empty($_POST['city']) && !empty($_POST['state']) && !empty($_POST['zip']) && !empty($_POST['country']) && !empty($_POST['phone']) && !empty($_POST['email']) && !empty($_POST['about']) && !empty($_POST['size'])){

    // Submitted form data
    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $apt = $_POST['apt'];
    $address = $_POST['address'];
    $city = $_POST['city'];
    $state = $_POST['state'];
    $zip = $_POST['zip'];
    $country = $_POST['country'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
    $about = $_POST['about'];
    $size = $_POST['size'];

    /*
     * Send email to admin
     */
	$to     = 'frontend.amzufia@gmail.com';
    //$to     = 'anassohail86@gmail.com';

    $subject= 'Contact Request Submitted';
    
    $htmlContent = '
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
    <h4>Contact request has submitted at Adsum Group, details are given below.</h4>
    <table cellspacing="0">
        <tr>
            <th align="left">First Name:</th><td>'.$firstname.'</td>
        </tr>
        <tr>
            <th align="left">Last Name:</th><td>'.$lastname.'</td>
        </tr>
        <tr>
            <th align="left">APT/SUITE/BOX:</th><td>'.$apt.'</td>
        </tr>
        <tr>
            <th align="left">Address:</th><td>'.$address.'</td>
        </tr>
        <tr>
            <th align="left">City:</th><td>'.$city.'</td>
        </tr>
        <tr>
            <th align="left">State:</th><td>'.$state.'</td>
        </tr>
        <tr>
            <th align="left">ZIP:</th><td>'.$zip.'</td>
        </tr>
        <tr>
            <th align="left">Country:</th><td>'.$country.'</td>
        </tr>
        <tr>
            <th align="left">Phone:</th><td>'.$phone.'</td>
        </tr>
        <tr>
            <th align="left">Email:</th><td>'.$email.'</td>
        </tr>
        <tr>
            <th align="left">How did you hear about us ?:</th><td>'.$about.'</td>
        </tr>
        <tr>
            <th align="left">What`s your preferred APT Size ?:</th><td>'.$size.'</td>
        </tr>
    </table>
    </body>
    </html>';
    
    // Set content-type header for sending HTML email
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
    
    // Additional headers
    //$headers .= "From: <alluch@verticalfarmingplus.com>" . "\r\n";
	
    // Send email
    if(mail($to,$subject,$htmlContent,$headers)){
        $status = 'ok';
    }else{
        $status = 'err';
    }
    
    // Output status
    echo $status;die;
}


?>
