Forum Moderators: coopster
I have mastered grabbing an array from the $_POST from a set of 12 check boxes and printing them in the web page using the isset/foreach combo, but am having trouble sending the same list to the email message.
Here is the post data:
$list = $_POST['list'];
and here is the properly working script that is printing within the body of the web page:
<?PHP if(isset($_POST['list'])){foreach($_POST['list'] as $value1) {
echo "<BR> " . $value1 , "\n";
}}else {echo "none";}
?>
It works great. But I want that same list to be printed in the email. I have added a foreach statement to create a new variable to send to the email message:
foreach($_POST['list'] as $listcat) {
$listcat = $list2;
}
and then just putting $list2 in the email body. But, not only is it not working, I think I am way off. I have tried putting the foreach lanaguage in the email message, but that did not work either.
Any thoughts would br greatly appreciatesd.
Thanks!
Pat
foreach($_POST['list'] as $listcat) { $listcat = $list2; } you are looking for:
foreach($_POST['list'] as $listcat) { # Append each list entry to $list2 and comma-separate $list2 .= $listcat.","; } # Clean extra comma off the end $list2 = substr($list2,0,-1); In the end,
$list2 would be a comma-separated string containing all of the values in the $_POST['list'] array. Or maybe even:
foreach($_POST['list'] as $listcat) { # Append each list entry to $list2 and add newline $list2 .= $listcat."\r\n"; } for a string with line breaks between each entry.