<?php 
$errors = '';
$myemail = 'info@steamcarpetrichmond.com';//<-----Put Your email address here.
if(empty($_POST['name'])  || 
   empty($_POST['tele']))
{
    $errors .= "\n Error: all fields are required";
}

$name = $_POST['name']; 
$tele = $_POST['tele'];
$email = $_POST['email']; 
$city = $_POST['city'];
$zip = $_POST['zip'];
$special_request = $_POST['special_request']; 

if( empty($errors))
{
	$to = $myemail; 
	$email_subject = "Appointment Request From: $name";
	$email_body = "You have received a new appointment request. ".
	" Here are the details of the request:\n 
	
	Name : $name \n 
	Contact Number : $tele \n 
	E-Mail : $email \n
	City : $city \n
	Zip Code : $zip \n
	Special Request : \n $special_request"; 
	
	
	
	$headers = "From: $myemail\n"; 
	$headers .= "Reply-To: $email_address";
	
	mail($to,$email_subject,$email_body,$headers);
	//redirect to the 'thank you' page
	header('Location: contact-form-thank-you.html');
} 
# spam protection
if (isset($_POST["spam"]) && $_POST["spam"] == "") {
	mail( 'info@steamcarpetrichmond.com', 'Contact Form', print_r($_POST,true) ); 
  } else {
	http_response_code(400);
	exit;
  }
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
	<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-8LV4MHWSTD"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-8LV4MHWSTD');
</script>
<title>Contact form handler</title>
</head>

<body>
<!-- This page is displayed only if there is some error -->
  <?php
echo nl2br($errors);
?>
</body>
</html>