Commit d9d88ef7 authored by sam.markey's avatar sam.markey

Delete sendEmailReceipt.php

parent 47b056b8
<?php
use PHPMailer\PHPMailer\PHPMailer;
if(isset($_POST['details']) && isset($_POST['emailAddress']) ){
$allDetails = json_decode($_POST['details']);
$allItemData = json_decode($_POST['itemData']);
//checks is valid email
$email = $_POST['emailAddress'];
if(!filter_var($email,FILTER_VALIDATE_EMAIL)){
echo 'invalidEmail';
die;
}
else{
//Email Address
// DETAILS
$museumName = $allDetails->museumName;
$dateSelected = $allDetails->dateSelected;
$timeSelected = $allDetails->timeSelected;
$totalCost = $allDetails->totalCost;
$amountEntered = $allDetails->amountEntered;
$change = $allDetails->change;
$bookingID = $allDetails->bookingID;
$userName = $allDetails->firstname;
$lastname = $allDetails->lastname;
$body = "Dear ".$userName."<br><br>
Here is Your Receipt.<br>Thank you for booking with World Museums! <br>
";
//ITEM DATA
$itemNames = $allItemData->ItemNames;
$itemQuantity = $allItemData->ItemQuantity;
$ItemPrices = $allItemData->ItemPrices;
//checking to see if user has bought items
$body .='<body>
<h3>----------------------ITEMS----------------------</h3><br>
<table>';
for($i = 0; $i < count($itemNames);$i++){
$body .='<tr><td style="text-align: center;">'.$itemNames[$i].
'</td><td style="text-align: center;">'
.$itemQuantity[$i].'</td><td style="text-align: center;">&amp;pound;'.$ItemPrices[$i].".00</td></tr>";
}
$body.='</table>';
$body .= '<h3>----------------------Details----------------------</h3>';
$body .= '<table><tr><td>Customer Name:</td><td>'.$userName." ".$lastname."</td></tr>"."<tr><td>MuseumName:</td><td>".$museumName.'</td></tr>'."<tr><td>Date:</td><td>".$dateSelected.'</td></tr>'
."<tr><td>Time Start:</td><td>".$timeSelected.'</td></tr>'."<tr><td>Total Cost:</td><td>".$totalCost."</td></tr>"."<tr><td>Amount Entered:</td><td>".$amountEntered.'</td></tr>'."<tr><td>Change
Given:</td><td>".$change."</td></tr>
</table>
<h2 style='color: #A40C01;'><b>BOOKING CODE: ".$bookingID."</b></h2>
<br> Thank you,<br> World Museums</body>";
PostEmail($body,$email,$userName,$bookingID);
}
}
else{
echo 'check Isset ';
}
function PostEmail($body,$usersEmail,$username,$bookingID){
require 'vendor/autoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'smtp.hostinger.co.uk';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = 'worldmuseums@sammarkey.com';
$mail->Password = 'ENTER PASSWORD HERE';
$mail->setFrom('worldmuseums@sammarkey.com', 'World Museums');
$mail->addAddress($usersEmail, $userName);
$mail->Subject = $username.' Your BOOKING CODE IS: '.$bookingID;
$mail->Body = html_entity_decode($body);
$mail->IsHTML(true);
if (!$mail->send()) {
echo 'failure';
}
else{
echo 'success';
}
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment