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

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

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

if(!isset($_POST['email1']) || $_POST['email1']=="")
{
	$error .=" \nEmail Id is required";
}
else
{
	if (!filter_var($_POST['email1'], FILTER_VALIDATE_EMAIL)) 
	{	
	
		$error .=" \nEnter valid Email Id";
	}
}

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

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

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


if ($error == "") {
    $to = 'platinumgroup.socialmedia@gmail.com, backupilogicx@gmail.com';
    $subject = 'Get in Touch  Form';

    $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['name1'] . "</td></tr>";
     $message_body .= "<tr><td>Contact's Email : </td><td>" . $_POST['email1'] . "</td></tr>";
    $message_body .= "<tr><td>Contact's Phone : </td><td>" . $_POST['phone1'] . "</td></tr>";
       $message_body .= "<tr><td>Contact's Cars : </td><td>" . $_POST['cars'] . "</td></tr>";
    $message_body .= "<tr><td>Contact's Message : </td><td>" . $_POST['message1'] . "</td></tr>";
    $message_body .= "</table></body></html>";

    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
    $headers .= 'From: lpplatinum devenvir' . "\r\n";

    if (mail($to, $subject, $message_body, $headers)) {
        echo "sent";
    } else {
        echo "Sorry, an error occurred this time sending your mail. Please send again..!";
    }
} else {
    echo $error;
}
?>