<?php 
// GoDaddy CPanel Email Handler
//
// Author: Jacob palasek
//
// Date: 07.26.2025
//
// Revised: 07.29.2025
//
// Added spam honey pot field. 
//

if(isset($_POST['c-us-submit'])){ 
        
	$to = "palasekj@compudocgr.net";
	$from = $_POST['em-address'];     
	$first_name = $_POST['f-name']; 
	$last_name = $_POST['l-name'];	
	$phone_number = $_POST['p-number'];	
	
	//$subject = "Compudoc TEST Contact Form Submission";
	//$subject = "Compudoc GR Contact Form Submission";	
	$subject = "Compudoc MTPL Contact Form Submission";	
	//$subject = "Mathdoc GR Contact Form Submission";	
	//$subject = "Mathdoc MTPL Contact Form Submission";	
	
	$questions_comments = $_POST['questions-comments']; 
	
	$message = $subject . ": " . "<br><br>";	
	$message .= "First Name: " . $first_name . "<br>";
	$message .= "Last Name: " . $last_name . "<br>";
	$message .= "Phone Number: " . $phone_number . "<br>";
	$message .= "Email Address: " . $from . "<br><br>";   
	$message .= "Questions or Comments:" . "<br>";	
	$message .= $questions_comments;	
	
	$headers = "From:" . $to . "\r\n";  	    	
    $headers .= "MIME-Version: 1.0" . "\r\n";	
    $headers .= "Content-Type: text/html; charset=iso-8859-1" . "\r\n";	
	$headers .=	"X-Mailer: PHP v".phpversion()."\r\n";
	$headers .= "X-Priority: 3\r\n"; // 1 = High, 3 = Normal, 5 = Low
	$headers .= "X-MSMail-Priority: Normal\r\n";
	$headers .= "Return-Path: <mail@compudocgr.com>" . "\n";
		
	if (!empty($_POST['c-em-address'])) {
		
		// If there is any text in that field it is propably a robot.
        header('Location: thank-you-sp.html');
		
    } else {        
		mail($to,$subject,$message,$headers);
        header('Location: thank-you.html');      
    }
}
?>