NeMoD Posted July 9, 2009 Share Posted July 9, 2009 How do I assign multiple strings to $body? if ($cart) { $to = "email@mail.com"; $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. Quote 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; Quote 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. Quote 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@mail.com"; $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 Quote Link to comment https://forums.phpfreaks.com/topic/165383-mail-and-body-troubles/#findComment-872219 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.