<?php
if(isset($_POST['contact'])){
    $Subject = 'Contact Us'; 
    $ToEmail = 'webdesignfivedesign@gmail.com';
    $me=$_POST['name'];
    $mailheader = "MIME-Version: 1.0" . "\r\n";
    $mailheader .= "Content-type:text/html;charset=UTF-8"."\r\n";
    $mailheader .='From : '.$_POST['email'].'\r\n'; 
    $MESSAGE_BODY= "";
    $MESSAGE_BODY .= "Name :- ".$_POST["name"]."<br>"; 
    $MESSAGE_BODY .= "Contact Person :- ".$_POST["phone"]."<br>";
    $MESSAGE_BODY .= "Email :- ".$_POST["email"]."<br>";
    $MESSAGE_BODY .= "Mobile No. :- ".$_POST["mobile"]."<br>"; 
    $MESSAGE_BODY .= "Registered Address :- ".$_POST["address"]."<br>";   
    $MESSAGE_BODY .= "Describe your requirement  :- ".$_POST["requirment"]."<br>"; 
    $MESSAGE_BODY .= "Number of Employees  :- ".$_POST["numberofemployees"]."<br>"; 
    $MESSAGE_BODY .= "Query  :- ".$_POST["query"]."<br>"; 
    
    $secretKey = "6Lcn9IcjAAAAAHS4iNBMS6bV4Bti30VG9-GHwaER";
    $responseKey = $_POST['g-recaptcha-response'];
    $url= "https://www.google.com/recaptcha/api/siteverify?secret=$secretKey&response=$responseKey";
    $response= file_get_contents($url);
    $response= json_decode($response);

    if($response->success)
    {
 if(mail($ToEmail, $Subject, $MESSAGE_BODY, $mailheader)){ 
        echo "<script> alert(' Thank you " .$me. " your message was sent '); </script>";
        echo "<script> window.location.href='contact.php'; </script>";
    }else{
        echo "<script> alert('Mail Not send'); </script>";
        echo "<script> window.location.href='contact.php'; </script>";
    }
    }else{
        echo "<script> alert('Verification Failed'); </script>";
        echo "<script> window.location.href='contact.php'; </script>";
    }




   
}
?>