<?php
error_reporting(0); 
 
$email=$_POST['email'];
if(isset($_POST['submit']))
{
$error = array();
if($_POST['name'] == ""){
$error[] = "Enter a name";
}
$email=$_POST['email'];
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email)){ 
$error[] = "Entered Email address is not Valid.";
} 
if($_POST['contact'] == ""){
$error[] = "Enter a Contact number";
}
if($_POST['message'] == ""){
$error[] = "Enter a Message";
} 
if($error){
	foreach($error as $listerror){
	echo $listerror;	
	}
//header("location:error.html");
} else {
	$to='sales@supersupportstaff.com';	
	$subject = 'Contact details'; 
	$message="<table>
	<tr>
	<td>Name: </td><td> $_POST[name]</td>
	</tr>	
	<tr>
	<td>Email: </td><td> $_POST[email]</td>
	</tr> 
	<tr>
	<td>Phone: </td><td> $_POST[contact]</td>
	</tr>	
	<tr>
    <td>Message: </td><td> $_POST[message]</td>
	</tr>
	</table>";
	 
      $headers .= "From: <sales@supersupportstaff.com>\r\n"; 		
	  $headers .= "Organization: Sender Organization\r\n";
	  $headers .= "MIME-Version: 1.0\r\n";
	  $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
	  $headers .= "X-Priority: 3\r\n";
	  $headers .= "X-Mailer: PHP". phpversion() ."\r\n"; 
	  $send = mail($to,$subject,$message,$headers);
	
	$to1=$email;	
	$subject1 = 'Welcome to Super Support Staff '; 
	$message1="<table>
	<tr>
	<td>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</td>
	</tr>	
 	<tr>
	<td>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</td></tr>	
	<tr><td>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</td></tr>
	<tr><td>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</td></tr>
	<tr>
    <td>Best Regards,<br /> 
		Name <br />
		Super Support Staff<br />
		PH: +(281)-899-0730<br />
		Email: sales@supersupportstaff.com
		</td>
	</tr>
	</table>";

  $headers1 .= "From: <sales@supersupportstaff.com>\r\n"; 		
  $headers1 .= "Organization: Sender Organization\r\n";
  $headers1 .= "MIME-Version: 1.0\r\n";
  $headers1 .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
  $headers1 .= "X-Priority: 3\r\n";
  $headers1 .= "X-Mailer: PHP". phpversion() ."\r\n"; 
  $send = mail($to1,$subject1,$message1,$headers1);

 	function storeAddress(){	
	if(!$_POST['email']){ return "No email address provided"; } 

	if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$/i", $_POST['email'])) {
		return "Email address is invalid"; 
	} 	
	$list_id = "264d3be589";
	$email=$_POST['email'];	 
	
}
storeAddress();
	if($send){
 	echo "<script>document.location.href='thankyou.html'</script>";
	} else {
	echo "mail not send";	
	}
}
}

?>
