Jump to content

problem sending mails (no subject)


kat32

Recommended Posts

<?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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.