<?php
session_start();
require('config.php');

      if(isset($_POST['submit'])){

		
		$siteKey     = '6LfoF30nAAAAAI6cuLEegEvzQoWRcOgexMR2O90V'; 
		$secretKey     = '6LfoF30nAAAAAHndOMXvU_632pTrOTLdV_4hJYCy'; 
		  
		  $name = $_POST['name'];
		 
		  $email = $_POST['email'];
		  $phone = $_POST['phone'];
		    $address = $_POST['address'];
		  $message1 = $_POST['message'];
		  $subject1 =  $_POST['subject'];
		
		  //print_r($_POST);
		  
       $query = "INSERT INTO contact(name,email,phone,message,address,subject) VALUES(:nm,:em,:tar,:cur,:addr,:sub) ";

       $stmt = $conn->prepare($query);

       $stmt->bindParam(':nm',$name);
      
       $stmt->bindParam(':em',$email);
       $stmt->bindParam(':tar',$phone);
       $stmt->bindParam(':cur',$message1);
	   $stmt->bindParam(':addr',$address);
	   $stmt->bindParam(':sub',$subject1);
     

       $result =  $stmt->execute();
	   
	   if($result){
		           
				 //$email = "info@icloudcs.com";  
				   
	             $headers  = 'MIME-Version: 1.0' . "\r\n";
             $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
             $headers .= "From: $email \r\n";
			 $headers .= "Reply-To: $emai1\r\n";
				$headers .= "Return-Path: $email\r\n";
				$headers .= "CC: sombodyelse@example.com\r\n";
			

     
	
		  $to = "info@evsaccountingsolutions.com";
				  /*  $headers = 'From: '.$email." \r\n" ;
					$headers .='Reply-To: '. $to . "\r\n" ;
					$headers .='X-Mailer: PHP/' . phpversion();
					$headers .= "MIME-Version: 1.0\r\n";
					$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";   */
		  

     
	
		    		//$to = "thawbuilders@gmail.com";
		   			$subject = "EVS/Contactus";
		  			$message =  '<html><body>';
			$message.='<table width="100%"; rules="all" style="border:1px solid #3A5896;" cellpadding="10">';
		 
		  	$message.= "<tr><td><strong>Contact Info</strong></td></tr>";
		  
			$message .= "<tr><td>Name: </td><td> ".$name."</td></tr>";
 
   
         
 
           	$message .= "<tr><td>Email </td><td> ".$email."</td></tr>";
			
				 $message .= "<tr><td>Phone: </td><td> ".$phone."</td></tr>";
				 
		    $message .= "<tr><td>Messages </td><td> ".$message1."</td></tr>";
		
		  $message .= "<tr><td>Address </td><td> ".$address."</td></tr>";
		  
		    $message .= "<tr><td>Subject </td><td> ".$subject1."</td></tr>";
			
          
			
			
				   
$message .= "</table>";
 
$message .= "</body></html>";
		
		
		
		 $retval = mail ($to,$subject,$message,$headers);
		 
		
   if( $retval == true )
   {
    $_SESSION['start_time'] = time();
                        $_SESSION['msg'] = "Data submitted and mail sent successfully";
						 header("location: contact-thanks.php"); 
   }
   else
   {
      $_SESSION['start_time'] = time();
                        $_SESSION['msg'] = "Data submitted but mail not sent successfully";
						 header("location: contact-thanks.php"); 
   }
		}
				
				   
		    
		   
		   }

	

















?>