<?php
/* No output to screen is generated from this page. A succesfull credit card transaction is redirected here with customers email and order number attached to url
2 database queries are executed to obtain the products in order and customers details. The retrieved data is emailed to 3 addressess at the moment:
customer`s email, me for testing purpose and owners website. All emails arrive in 2 copies. The linked pages have no email functions
*/
date_default_timezone_set("Pacific/Auckland");
//database credentials
include ("../cp/kiaora.dora");
include ("../cp/db.dora");
//obtain customer details
$sql = "SELECT email, fname, lname, phone, street, suburb, city, postCode, country, fnameShip, lnameShip, streetShip, suburbShip, cityShip, postCodeShip, countryShip FROM customers WHERE email='" . $_GET['email'] . "'";
$result = mysql_query($sql) or die(mysql_error());
while ($results = mysql_fetch_array($result)) {
$orderno = $results['orderno'];
$email = $results['email'];
$fname = $results['fname'];
$lname = $results['lname'];
$phone = $results['phone'];
$street = $results['street'];
$suburb = $results['suburb'];
$city = $results['city'];
$postCode = $results['postCode'];
$country = $results['country'];
$fnameShip = $results['fnameShip'];
$lnameShip = $results['lnameShip'];
$phoneShip = $results['phoneShip'];
$streetShip = $results['streetShip'];
$suburbShip = $results['suburbShip'];
$cityShip = $results['cityShip'];
$postCodeShip = $results['postCodeShip'];
$countryShip = $results['countryShip'];
}
//start creating the email`s body
$orderItems = "Status: Payment received, thank you.<br /><br /><b>Bill to</b><br />$fname $lname<br />Address: $street $suburb<br />$city $postCode<br />Country: $country<br /><br /><br /><b>Ship to</b><br />$fnameShip $lnameShip<br />Address: $streetShip $suburbShip<br />$cityShip $postCodeShip<br />Country: $countryShip<br /><br />";
//items in order query
$sql = "SELECT orderno, item_id, item_name, item_price, item_qty, total FROM shopping_cart WHERE orderno='" . $_GET['orderno'] . "'";
$result = mysql_query($sql) or die(mysql_error());
$orderItems .= "<p>Items in order</p><table width=\"90%\" border=\"0\" cellpadding=\"5\"><tbody><tr><td><b>Item</b></td><td><b>Price</b></td><td><b>Quantity</b></td></tr><tr><td colspan=\"3\"><hr/></td></tr>";
while ($items = mysql_fetch_array($result)) {
$orderno = $items['orderno'];
$name = $items['item_name'];
$price = $items['item_price'];
$qty = $items['item_qty'];
$total = $items['total'];
//define shippingCharge to add it to email body if there is post charge
$shippingCharge="";
//if total different price of all items together will set shipping charge to a message that $ 5 from total is shipping charge
if($price!==$total){$shippingCharge="(Includes 5 \$ shipping charge)";}
//adding the order items to email and finishing the email
$orderItems .= "<tr><td>$name</td><td>$price NZD</td><td>$qty</td></tr>";
}$orderItems .= "</table><br /><strong>Total: $total \$ $shippingCharge</strong><p>Your order will be shipped next business day.<br />Any enquiries contact <a href=\"mailto:orders@everhealthpharmacy.co.nz?Subject=Order $orderno\" title=\"Contact us\">orders@everhealthpharmacy.co.nz</a><br />Phone: 07 849 3805 Please quote order number $orderno</p><em>The team at Everhealth Pharmacy</em>";
//getting new zealand times
$date = date("l, F jS, Y");
$time = date("h:i A");
//email to customer
$to = $_GET['email'];
$subject = "Everlife Pharmacy ORDER NO. $orderno placed. Credit Card Order";
$message = $orderItems;
$headers = "From: [email]orders@everhealthpharmacy.co.nz[/email]\r\n";
$headers .= "Content-type: text/html\r\n";
mail($to, $subject, $message, $headers);
//email to developer
$to = "julianstefan@focusdesign.biz";
mail($to, $subject, $message, $headers);
//email to website owner
$to = "orders@everhealthpharmacy.co.nz";
mail($to, $subject, $message, $headers);
//destroy session to clear the shopping card
unset ($_COOKIE["PHPSESSID"]);
setcookie("PHPSESSID", "", time() - 3600, "/");
//redirection to next page
header("Location:http://www.everhealthpharmacy.co.nz?cc=1");
?>
Bookmarks