PDA

View Full Version : Emailing session contents


wap3
12-11-2002, 02:51 PM
Hello everyone, :)

I amtrying to figure out how I can email the results of a form and the details in my session.

This is the code I have for it so far. It emails the form details, thats not the problem. The problem is sending the session details.
I tried to add something to the bottom whihc you can see to try and get it to email it to me but it doesn't work.

Can I do it like this ?? Any ideas on how it can be done ??

Thanks guys

:thumbsup:


function mail_basket($formvars) {
$ouraddress = "email@domain.co.uk";
$subject = "Form and session content";
$content = "The following details are from the form and sesison"."\n\n"
."-------------------------------------------------------"."\n"
."Personal Details"."\n"
."-------------------------------------------------------"."\n\n"
."Title: ".$formvars[title]."\n"
."First Name: ".$formvars[firstname]."\n"
."Last Name: ".$formvars[lastname]."\n"
."Address: ".$formvars[address]."\n"
."Postcode: ".$formvars[postcode]."\n\n"
."Telephone: ".$formvars[telephone]."\n"
."E-mail: ".$formvars[email]."\n\n"
."Comments: ".$formvars[comments]."\n\n"
."Hiredate: ".$formvars[hiredate]."\n\n"
."Estimated Duration: ".$formvars[duration]."\n\n";

foreach($_SESSION['cart'] as $Item_id => $quantity) {
$item = get_items_forbasket($Item_id)
foreach ($item as $row) {
$items = "Quantity: ".$quantity."\n"
."Item: ".$row[Description]."\n"
."Weekly Rate: ".$row[One_Week]."\n"; }
}
$additional_headers = "From: ".$formvars[email]."\n";
mail($ouraddress, $subject, $content . $items, $additional_headers);
return true;
}

wap3
12-11-2002, 03:14 PM
Ok I have edited that code now. Because I managed to get it to output the form details and the last item in the session variable.

Can somebody tell me why its not printing all the items in the array, just the last one instead ??

thanks

:thumbsup:

Transistor
12-11-2002, 11:32 PM
foreach ($item as $row) {
$items .= "Quantity: ".$quantity."\n"
."Item: ".$row[Description]."\n"
."Weekly Rate: ".$row[One_Week]."\n";
}

You were missing a period BEFORE the equal sign.

wap3
12-12-2002, 12:22 PM
:rolleyes: oh how annoying I had it in orignially. But then it got deleted when I edited the code and I forgot to put it back in !!

thanks very much anyway transistor

:thumbsup: