NeMoD Posted July 9, 2009 Share Posted July 9, 2009 How do I assign multiple strings to $body? if ($cart) { $to = "[email protected]"; $subject = "my subject"; $body .= $_POST['firstname']; $body .= $_POST['lastname']; $body .= $_POST['street']; $body .= $_POST['zipcode']; $body .= $_POST['country']; $body .= $_POST['email']; $body .= $_POST['phonenumber']; if (is_array($_SESSION[mailorder])) { foreach($_SESSION[mailorder] as $key => $val) { $body .= $val . PHP_EOL; } } if (mail($to, $subject, $body)) { echo('<p>Order Submitted!'); } else { echo('<p>Order failed, please try again!'); } } $mailorder is an array containing all the product numbers, that part is working fine. Link to comment https://forums.phpfreaks.com/topic/165383-mail-and-body-troubles/ Share on other sites More sharing options...
ignace Posted July 9, 2009 Share Posted July 9, 2009 $body .= $string1 . $string2 . $string3; Link to comment https://forums.phpfreaks.com/topic/165383-mail-and-body-troubles/#findComment-872209 Share on other sites More sharing options...
phporcaffeine Posted July 9, 2009 Share Posted July 9, 2009 Where one issue may be in your code is references to: $_SESSION[mailorder] ... it should be $_SESSION['mailorder'] (notice the use of the single quote). Other than that it should work fine. Link to comment https://forums.phpfreaks.com/topic/165383-mail-and-body-troubles/#findComment-872217 Share on other sites More sharing options...
NeMoD Posted July 9, 2009 Author Share Posted July 9, 2009 It's only sending the product numbers from $mailorder ??? if ($cart) { $to = "[email protected]"; $subject = "my subject"; if (is_array($_SESSION['mailorder'])) { foreach($_SESSION['mailorder'] as $key => $val) { $body .= $val . PHP_EOL; } } $body .= $_POST['firstname'].$_POST['lastname'].$_POST['street'].$_POST['zipcode'].$_POST['country'].$_POST['email'].$_POST['phonenumber']; if (mail($to, $subject, $body)) { echo('<p>Order Submitted!'); } else { echo('<p>Order failed, please try again!'); } } Where one issue may be in your code is references to: $_SESSION[mailorder] ... it should be $_SESSION['mailorder'] (notice the use of the single quote). Other than that it should work fine. put the quotes in, still only sends the product numbers from mailorder Link to comment https://forums.phpfreaks.com/topic/165383-mail-and-body-troubles/#findComment-872219 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.