<?php
if(isset($_POST['contactFrmSubmit']) && !empty($_POST['fname']) && !empty($_POST['email']) && (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) && !empty($_POST['lname']) && !empty($_POST['cname']) && !empty($_POST['role']) && !empty($_POST['phone']) ){
    
    // Submitted form data
    $fname   = $_POST['fname'];
    $lname  = $_POST['lname'];
    $cname   = $_POST['cname'];
    $role   = $_POST['role'];
    $email  = $_POST['email'];
    $phone   = $_POST['phone'];

    
    /*
     * Send email to admin
     */
    $to     = 'info@metisbenefits.com';
	//$to     = 'frontend.amzufia@gmail.com';
    $subject= 'Contact Request Submitted';
    
    $htmlContent = '
    <h4>Contact request has submitted at METIS, details are given below.</h4>
    <table cellspacing="0" style="width: 300px; height: 200px;">
        <tr>
            <th>First Name:</th><td>'.$fname.'</td>
        </tr>
        <tr>
            <th>Last Name:</th><td>'.$lname.'</td>
        </tr>

        <tr>
            <th>Company Name:</th><td>'.$cname.'</td>
        </tr>

        <tr>
            <th>Role:</th><td>'.$role.'</td>
        </tr>

        <tr style="background-color: #e0e0e0;">
            <th>Email:</th><td>'.$email.'</td>
        </tr>

        <tr>
            <th>Phone:</th><td>'.$phone.'</td>
        </tr>

		
    </table>';
    
    // 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: Metis<info@metisbenefits.com>' . "\r\n";
    
    // Send email
    if(mail($to,$subject,$htmlContent,$headers)){
        $status = 'ok';
    }else{
        $status = 'err';
    }
    
    // Output status
    echo $status;die;
}


?>
