$sql ="SELECT * FROM customer WHERE customerID = '$custID'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$to = $row['email'];
$subject = "Order confirmation from 'www.iwtgadget.com'";
$random_hash =md5(date('r', time()));
$headers = "From: sales@iwtgadget.com\r\nReply-To: sales@iwtgadget.com";
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
ob_start();
?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<? include ("confirm_email.php"); ?>
--PHP-alt-<?php echo $random_hash; ?>--
<?
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
<-- included table -->
<body bgcolor="#ECD078">
<table width="500px" style="font-family: sans-serif">
<tr>
<td colspan="3" align="center"><img style="margin:0 auto" src="http:/www.iwtgadget.com/images/logo.gif" alt="I Want That Gadget" width="166" height="142" /></td>
</tr>
<form id="buy" method="post" action="buy_confirm.php">
<input type="hidden" id="orderID" value="" />
<tr>
<td colspan="3" style="border-bottom:1px solid #000"><font size="+2"><p>Your order has been successful, thank you!</p></font>
</td>
<tr>
<td width="247" style="text-align:left"><u><b>Item name</b></u></td><td width="138" style="text-align:left"><u><b>Quantity</b></u></td><td width="99" style="text-align:right"><u><b>Price</b></u></td>
</tr>
<?
foreach($_SESSION['cart'] as $prodID => $quantity) {
$sql = sprintf("SELECT prodName, shortDescription, price FROM product WHERE productID = %d;", $prodID);
$result = mysql_query($sql);
$name = $row['prodName'];
$description = $row['shortDescription'];
$price = $row['price'];
list($name, $description, $price) = mysql_fetch_row($result);
$line_cost = $price * $quantity;
$total = $total + $line_cost;
?>
<input type="hidden" id="id" value="<? $row['productID'];?>" />
<tr>
<td align="left"><? echo $name; ?></td>
<td align="left"><? echo $quantity; ?> </td>
<td align="right">£<? echo $line_cost; ?></td>
</tr>
<?
}
?>
<tr>
<td colspan="3" style="border-bottom:1px solid #000" align="right"><b>Free Delivery</font></td>
</tr>
<tr>
<td colspan="2" align="right">Total</td>
<td align="right" style="border-bottom:1px solid #000 ; border-top:1px solid #000"><b>£<? echo $total; ?></b></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3" style="text-align:justify">Your order is being processed for dispatch. Once it has been dispatched an email will be sent to you to confirm the estimated delivery date</td>
</tr>
</form>
</table>
</body>