PHP Output of a foreach included in a mail variable

I want to include the output of a foreach loop + echo $total as the variable $order in my sendmail.php. Can somebody help me? I am a bit stuck.

My sendmail.php:

<?php
if(!isset($_SESSION)) {
     session_start();
}

$to = $_SESSION['email'];
$firstname = $_SESSION['firstname'] ;
$lastname = $_SESSION['lastname'] ;
$email = $_SESSION['email'] ;
$addressline1 = $_SESSION['addressline1'] ;
$towncity = $_SESSION['towncity'] ;
$postcode = $_SESSION['postcode'] ;

foreach ($_SESSION['invoice'] as $value) { //needs to = $order
    echo $value."<br>";} //needs to = $order
echo "Total: $".$_SESSION['total']; //needs to = $order

//set subject
$subject = "Crystal Fusion - New Order";

//body of the e-mail
$body = "New Order Received:\n\n\n\n
    From: $firstname $lastname\n
    Email: $email\n
    Address: $addressline1\n
    Town/City: $towncity\n
    Postcode: $postcode\n
    Order: $order"; //needs to = foreach loop above

$sent = mail($to, $subject, $body);

if($sent)
    {echo "<script language=javascript>window.location = 'mail_succeed.php';</script>";}
else
    {echo "<script language=javascript>window.location = 'mail_fail.php';</script>";}
?>

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories