<?php

if(isset($_POST["Send"])) {
	// Read the form values
	$success = false;
	echo $orderid = isset( $_POST['orderid'] ) ? preg_replace( "/[^\s\S\.\-\_\@a-zA-Z0-9]/", "", $_POST['orderid'] ) : "";
	echo $fName = isset( $_POST['fName'] ) ? preg_replace( "/[^\s\S\.\-\_\@a-zA-Z0-9]/", "", $_POST['fName'] ) : "";
	echo $qty = isset( $_POST['qty'] ) ? preg_replace( "/[^\s\S\.\-\_\@a-zA-Z0-9]/", "", $_POST['qty'] ) : "";
	echo $Address = isset( $_POST['Address'] ) ? preg_replace( "/[^\s\S\.\-\_\@a-zA-Z0-9]/", "", $_POST['Address'] ) : "";
	echo $senderEmail = isset( $_POST['email'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['email'] ) : "";
	echo $message = isset( $_POST['contact_message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['contact_message'] ) : "";
	
	
	$tmp_name = $_FILES['file']['tmp_name']; // get the temporary file name of the file on the server
    $name     = $_FILES['file']['name']; // get the name of the file
    $size     = $_FILES['file']['size']; // get size of the file for size validation
    $type     = $_FILES['file']['type']; // get type of the file
    $error     = $_FILES['file']['error']; // get the error (if any)
    
	//Headers
	$to ="me@amobimoseseche.com"; //$senderEmail;
    $subject = 'Contact Us';
	$headers  = 'From: Amobi Book Purchase  <me@amobimoseseche.com>' . "\r\n";
	$headers  = 'CC: Amobi  <godwinomuha14@gmail.com>' . "\r\n";
	$headers .= "MIME-Version: 1.0\r\n";
	$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
	
	require "emailalert.php";
	//body message
	//echo  $message = "Your Name: ". $fName . "<br> Company Name: ". $qty . "<br> Email: ". $senderEmail . "<br> phone: ". $qty . "<br> Message: " . $Address . "";
	
	//Email Send Function
    $send_email = mail($to, $subject, $message, $headers);
      
    echo ($send_email) ? '<div class="success alert alert-success text-center rounded-pill mt-2">Email has been sent successfully.</div>' : 'Error: Email Error.';
header("Location: https://amobimoseseche.com/");
}
else
{
	echo '<div class="failed alert alert-danger text-center rounded-pill mt-2">Failed: Email not Sent.</div>';
}

//=================================================================================

if(isset($_POST["femail"])) {
	// Read the form values
	$success = false;
	$senderEmail = isset( $_POST['femail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['femail'] ) : "";
	$message = isset( $_POST['femail'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['femail'] ) : "";
	
	//Headers
	$to = "info@footprint.com.ng";
    $subject = 'Footprint Newsletter Request';
	$headers  = 'From: Footprint Newsletter <info@footprint.com.ng>' . "\r\n";
	$headers .= "MIME-Version: 1.0\r\n";
	$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
	
	//body message
	$message = "Email: ". $senderEmail . "<br> Message: " . $message . "";
	
	//Email Send Function
    $send_email = mail($to, $subject, $message, $headers);
      
    echo ($send_email) ? '<div class="success alert alert-success text-center rounded-pill mt-2">Email has been sent successfully.</div>' : 'Error: Email did not send.';
}
else
{
	echo '<div class="failed alert alert-danger text-center rounded-pill mt-2">Failed: Email not Sent.</div>';
}



?>