<?php 
//print_r($_POST);exit();
$error="";

if(!isset($_POST['name']) || $_POST['name']=="")
{
	$error .="\nName is required";
}

else
{
	if(!preg_match('/^[a-zA-Z\\s]*$/',$_POST['name']))
	{
		$error .="\nEnter valid Name";
	}
}

if(!isset($_POST['email']) || $_POST['email']=="")
{
	$error .=" \nEmail Id is required";
}
else
{
	if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) 
	{	
	
		$error .=" \nEnter valid Email Id";
	}
}
if(!isset($_POST['phone']) || $_POST['phone']=="" || trim($_POST['phone'])=="")
{
	$error .=" \nPhone is required";
}
if(!isset($_POST['company_name']) || $_POST['company_name']=="" || trim($_POST['company_name'])=="")
{
	$error .=" \nCompany Name is required";
}
if(!isset($_POST['address_city']) || $_POST['address_city']=="" || trim($_POST['address_city'])=="")
{
	$error .=" \nAddress is required";
}


if(!isset($_POST['message']) || $_POST['message']=="" || trim($_POST['message'])=="")
{
	$error .=" \nMessage is required";
}

if($error=="")
{

    require 'PHPMailer/PHPMailerAutoload.php';
        $mail = new PHPMailer;
        $message_body="<html><body><table border=5px>";
        $message_body.="<tr><td colspan='2' style='color : #C50B33; font-size : 20px; '><b>Request For Contact</b></td></tr>";
        $message_body.="<tr><td>Contact's Full Name : </td><td>".$_POST['name']."</td></tr>";
       
        $message_body.="<tr><td>Contact's email : </td><td>".$_POST['email']."</td></tr>";
        $message_body.="<tr><td>Contact's phone : </td><td>".$_POST['phone']."</td></tr>";
         $message_body.="<tr><td>Contact's company name : </td><td>".$_POST['company_name']."</td></tr>";
         $message_body.="<tr><td>Contact's address : </td><td>".$_POST['address_city']."</td></tr>";
        $message_body.="<tr><td>Contact's Message : </td><td>".$_POST['message']."</td></tr>";
        $message_body.="</table></body></html>"; 
     
       
      //$mail->addAddress('hr@citifragindia.com');
        $mail->addAddress('rajashripawar104@gmail.com');
         $mail->addAddress('baligaikwad118@gmail.com');
        
    //  $mail->addAddress('baligaikwad118@gmail.com');
//   $mail->addAddress('dikshaahire46064@gmail.com');
       // $mail->AddAttachment( $_FILES['file']['tmp_name'], $_FILES['file']['name'] );
        $mail->Subject  = 'Contact Form';
        $mail->isHTML(true);
        $mail->Body = $message_body;

        if(!$mail->send())
         {
            echo "Sorry, error occured this time while sending your Mail.Please send again..!";
        } 
        else 
        {
            echo "sent";
        }
        $mail->ClearAllRecipients();
        //$mail->clearAttachments();
        $mail->addAddress($_POST['email']);
        $message_body="Thank You....We Will Back To You Soon..";
        $mail->Subject  = 'Contact Form';
        $mail->Body = $message_body;
        $mail->send();
         


}
else
{	
	echo $error;
}
?>