I'm trying to send an HTML email receipt from a shopping cart purchase but I don't get how to echo the session array within the EOF area. php doesn't seem to want to execute here. Thoughts?
//begin of HTML message
$message = <<<EOF
<html>
<body style="font-family: 'Myriad Pro', 'DejaVu Sans Condensed', Helvetica, Arial, sans-serif;
font-size:10px;"><center>
<table width="750" cellpadding="0" cellspacing="0" class="view-cart" style="text-
align:center;padding:5px;"><tr>
<tr><td>Image</td><td>SKU</td><td>Description</td><td>QTY</td><td>Price</td><td> </td></tr>
<tr>
foreach ($_SESSION["products"] as $cart_itm)
{
echo '<td><img src="'.$cart_itm['image'].'"></td>';
echo '<td>';
echo '<div class="p-code">'.$cart_itm["code"].'</td>';
echo '<td align="left">'.$cart_itm["description"].'</td>';
echo '<td>'.$cart_itm["qty"].'</td>';
echo '<td><div class="p-price">'.$cart_itm["price"].' each</div></td>';
echo '<td></td>';
echo '</tr>';
}
</table>
</center>
</body>
</html>
EOF;
//end of message
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
mail($to, $subject, $message, $headers);
The updated code now looks like this. I replaced the "$message +=" with "$message .=" and it seems to work fine now. :
//begin of HTML message
$message = <<<EOF
<html>
<body style="font-family: 'Myriad Pro', 'DejaVu Sans Condensed', Helvetica, Arial, sans-serif; font-size:10px;"><center>
<table width="750" cellpadding="0" cellspacing="0" class="view-cart" style="text-align:center;padding:5px;">
<tr><td>Image</td><td>SKU</td><td>Description</td><td>QTY</td><td>Price</td><td> </td></tr>
<tr>
EOF;
foreach ($_SESSION["products"] as $cart_itm)
{
$message .= "<td><img src=".$cart_itm['image'].">";
$message .= "</td><td>".$cart_itm['code'];
$message .= "</td><td>".$cart_itm['description'];
$message .= "</td><td>".$cart_itm['qty'];
$message .= "</td><td>".$cart_itm['price'] ;
$message .= "each</td><td></td></tr>";
}
$message2 = <<<EOF
</table>
<hr><table width="750" cellpadding="0" cellspacing="0" class="view-cart"><tr>
<td align="right"><b>Shipping: $ $shipping </b><br><b>Total: $ $total </b></td></tr></table>
</center>
</body>
</html>
EOF;