farnoise Posted December 1, 2009 Share Posted December 1, 2009 Hi, I have this code, Can any body tell me how can I send the output of $language into mail? This is a code that recieve the variable for bunch of check boxes from MY HTML form and echo the in my page but If you see bottom of the page i Have $message function that sends and e-mail to visitor with his list but I dont know how can I add this lists into my $message body. this PHP code is proccessing a HTML form and sends an email to me and to visitor, everything works fine except that part. This is where php check my boxes ________$LANGUAGE___________ if(isset($_POST['language'])) { $language = $_POST['language']; $n = count($language); $i = 0; echo "The languages you selected are \r\n" . "<ol>"; while ($i < $n) { echo "<li>{$language[$i]}</li> \r\n"; $i++; } echo "</ol>"; } __________________________ ____$MESSAGE______ $message = " New list has been submited $firstname , $lastname Start date: $date Your list is: I NEED THE CODE HERE " ...........Rest of the code............. ____$MESSAGE______ Thanks a lot guys Quote Link to comment https://forums.phpfreaks.com/topic/183627-message-function-plz-help-so-easy/ Share on other sites More sharing options...
mikesta707 Posted December 1, 2009 Share Posted December 1, 2009 just use a loop? $language = $_POST['language']; //other stuff $message = "whatever";//whatever comes before the list foreach($language as $lang){ $message .= $lang."\r\n"; } Quote Link to comment https://forums.phpfreaks.com/topic/183627-message-function-plz-help-so-easy/#findComment-969192 Share on other sites More sharing options...
Alex Posted December 1, 2009 Share Posted December 1, 2009 Do you need to echo the list as well as send it in the message? If so it would be preferable to use output buffering. Ex: if(isset($_POST['language'])) { ob_start(); $language = $_POST['language']; $n = count($language); $i = 0; echo "The languages you selected are \r\n" . "<ol>"; while ($i < $n) { echo "<li>{$language[$i]}</li> \r\n"; $i++; } echo "</ol>"; $list = ob_get_contents(); } You can then use $list inside of $message. Quote Link to comment https://forums.phpfreaks.com/topic/183627-message-function-plz-help-so-easy/#findComment-969194 Share on other sites More sharing options...
farnoise Posted December 1, 2009 Author Share Posted December 1, 2009 THANKS GUYS!!!! YOU ARE AWESOME..... Quote Link to comment https://forums.phpfreaks.com/topic/183627-message-function-plz-help-so-easy/#findComment-969197 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.