<?php

if ($_SERVER['REQUEST_METHOD'] === 'POST') 
{
    $to = 'sales@euctechnowood.com';
    $from = $_POST['email'];

    $name=$_POST['name'];
	$email=$_POST['email'];
    $phone=$_POST['contact'];
	$location=$_POST['location'];
	$company=$_POST['company'];
	$msg=$_POST['message'];
	$product=$_POST['productname'];
	$word = "http"; 
 
    
    
     $subject = 'Enquiry Mail';
    
    // Append additional fields to the message
    $message .= "Name: " . $name . "\r\n";
    $message .= "Phone: " . $phone . "\r\n";
    $message .= "Email: " . $email . "\r\n";
    $message .= "Location: " . $location . "\r\n";
    $message .= "Company: " . $company . "\r\n";
     $message .= "Product: " . $product . "\r\n";
    $message .= "Message: " . $msg . "\r\n";
  
  



   
        $boundary = md5(uniqid());

        // Headers
        $headers = "From: $from\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";

        // Message content
        $body = "--$boundary\r\n";
        $body .= "Content-Type: text/plain; charset=\"utf-8\"\r\n";
        $body .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
        $body .= $message . "\r\n\r\n";

     
        // Send the email
        if (mail($to, $subject, $body, $headers)) {
            // echo "Email sent successfully!";
          
          
          
                  
	  if ($product === "Alphacam") {
    // Redirect to the index page
    header('Location: assets/img/brochure/alphacam.pdf');
    // exit; // Make sure to exit after the redirect
     } 
     if ($product === "Cabinet vision"){
    header('Location: assets/img/brochure/cabinet_vision.pdf');
     }
     if ($product === "Peps"){
    header('Location: assets/img/brochure/peps.pdf');
     }
     if ($product === "Visi"){
    header('Location: assets/img/brochure/visi.pdf');
     }
     if ($product === "Worknc"){
    header('Location: assets/img/brochure/worknc.pdf');
     }

          
   

    //   header('Location:thank-you.html');
	  }

 
else
 {
   include('brochure.html?Message=error');
}
}
?>
 