I have a simple shopping cart allowing lunch items to be placed in it. When ready, there's a form the customer completes with necessary information. When the "Place Order" button is pushed, it takes the customer to a "receipt". I can get all the customer information into the e-mail but I can't seem to get the table of items to send in the e-mail.
Here's my e-mail build -
[FONT="Courier New"] //start building the mail string
$body = "<p><b>Name:</b> $username</p>";
$body .= "<p><b>E-mail:</b> $email</p>";
$body .= "<p><b>Phone:</b> $phone</p>";
$body .= "<p><b>Department:</b> $dept</p>";
$body .= "<p><b>Refrigerator:</b> $fridge</p>";
$body .= "<p><b>Delivery Date:</b> $ddate</p>";
$body .= "<p><b>PrePay Account:</b> $prepaynum</p>";
$body .= "<p><b>Department PO:</b> $deptpo</p>";
$body .= "<p><b>Date Ordered:</b> $datestamp</p>";
//need to put the items purchased here..
//set up the mail
$recipient = "email@example.com";
$subject = "Order from $_POST[username]";
$mailheaders = "MIME-Version: 1.0\r\n";
$mailheaders .= "Content-type: text/html; charset=ISO-8859-1\r\n";
$mailheaders .= "From: $_POST[username] <$_POST[email]> \n";[/FONT]
Here's the code I used to send the mail:
[FONT="Courier New"]<?php
$formmail=mail($recipient, $subject, $body, $mailheaders);
if($formmail==0)
{
echo("<h3>Sorry but it didn't work!</h3>");
}
else
{
echo "<h3><em>Thank you, <em>$username</em>, your order was sent!</em></h3>";
echo "<p><em>Ordered on:</em> $datestamp</p>";
}
}
?>[/FONT]
Here's how I'm getting the table of purchased items to display on the page,
I'm using a for loop to get the items in the table:
[FONT="Courier New"]<?php
for($i=1; $i<=count($SESSION['order']); $i++)
{
?>
<tr>
<td><?php echo $SESSION['order'][$i]['name'] ?></td>
<td><?php echo $SESSION['order'][$i]['description'] ?></td>
<td class="aligncenter"><?php echo $SESSION['order'][$i]['qty'] ?></td>
<td class="alignright"><?php echo $SESSION['order'][$i]['price'] ?></td>
<td class="alignright"><?php echo $SESSION['order'][$i]['qty']$SESSION['order'][$i]['price'] ?></td>
</tr>
<tr class="total">
<?php
$orderTotal=$orderTotal+($SESSION['order'][$i]['qty']$_SESSION['order'][$i]['price']);
}
?>
<td colspan="4" class="alignright"><h4>Order Total $</h4></th>
<td class="alignright"><h4><?php echo $orderTotal ?></h4> </tr>
</table>[/FONT]
Any ideas? Is it possible? I'm wondering if it's not working because of the $_SESSION variable???
Thanks!