kat32 Posted December 18, 2009 Share Posted December 18, 2009 <?php session_start(); require 'common.php'; ob_start(); $member_logged_in=$_SESSION['member_logged_in']; if( isset($_POST['send']) && $_POST['sub'] ){ $fullname = $_POST['fullname']; $email = $_POST['email']; $subject = $_POST['sub']; $body=$_POST['body']; for ($i=0; $i<count($email); $i++) { if($_POST['email'][$i]!=""){ $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $sent=mail($email[$i], $subject[$i], $body[$i], $headers); if($sent) echo 'Message sent'; } } } ?> <form method="post"> <table> <tr><td>Full Name</td><td>Please Check</td><td>Subject</td></tr> <?php // $q = mysql_query("SELECT * FROM mailinglists") or die(mysql_error()); while($row = mysql_fetch_array($q)){ $fullname=$row['fullname']; $email=$row['email'];?> <tr> <td><?php echo $fullname; echo '<input type="hidden" value="'.$fullname.'" name="fullname[]" />';?></td> <td><input type="checkbox" name="email[]" value="<?php echo $email; ?>" /></td> <td><select name="sub[]"> <?php $q2 = mysql_query("SELECT * FROM composemails") or die(mysql_error()); while($row = mysql_fetch_array($q2)){ $subject=$row['subject']; echo '<option value="'.$subject.'">'.$subject.'</option>'; } ?> </select> </td> <?php $q3 = mysql_query("SELECT * FROM composemails") or die(mysql_error()); while($row = mysql_fetch_array($q3)){ $body=$row['body']; echo '<input type="hidden" value="'.$body.'" name="body[]" />'; } ?> </tr><?php } ?> <tr><td><input type="submit" value="Send Email" name="send"/></td></tr> </table> </form> I have inserted names and email addresses in the table mailinglists. I have inserted also the subject and body in the table composemails, so that users will need to select subject for every person in the mailing list. I check all the checkbox then send and it worked fine. The subject is blank when I send an email to the second or last name in the mailing list. When I open the email of the second or last person in the mailing list, "[No Subject]" appeared. I really need your help. Quote Link to comment Share on other sites More sharing options...
teynon Posted December 18, 2009 Share Posted December 18, 2009 You need to output the arrays as your sending it to confirm that those values are not in fact empty. Do a print_r($subject); Quote Link to comment 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.