Hello Guys,

I am not really sure how to ask this, but i will try my best, as much help will be apericiated.

I have a saved.php page which echos all saved data that i have filled inluding customer email. I then want a email.php to have echoing all emails stored, but i want a check box which when i tick and press submit sends a mass email to all users that i have checked.

Can someone please point me to the right direction or give a tutorial which shows similar to what i want.

Thank you

Hi,

I hope you know how to send a mail to a user in php. If you know this, then the below code can help you.

Basic idea: Show a checkbox in front of every email id. Select and click a submit button to send emails to the selected email ids.

<?
if($_POST['submit'] == "Send Mass Mail")
{
// When someone presses submit button given below

    if(count($_POST['email_ids']) >0)
    {
        foreach($_POST['email_ids'] as $key)
        {
             //mail function - (to_field, subject_field,msg_field,headers)
             // Set it accordingly
             $subject = "Your mailer subject";
             $to = $key;
             $msg = "Here is our product";
             mail($to,$subject,$msg,$header);
        }
    }
}

?>

// This is the form that shows all the emails and the checkboxes

<form name="emailfrm" method="post" action="">
<table border="0" cellpadding="2" cellspacing="1">
    <thead>
        <tr>
             <th>Email Id</th>
            <th>&nbsp;</th>
        </tr>
    </thead>
    <tbody>
       <?php
        $res = mysql_query("Select email from <tablename>");
        while($data = mysql_fetch_array($res))
        {
         // Show all the emails from the database. Choose the tablename above
        ?>
        <tr>
             <td><?php echo $data['email']; ?></td>
             <td><input type="checkbox" name="email_ids" id="email_ids" value="<?php echo $data['email']; ?>" /></td>
        </tr>
        <?php
        }
        ?>
        <tr>
             <td colspan="2"><input type="submit" name="submit" id="submit" value="Send Mass Mail" />
        </tr>
     </tbody>
</table>
</form>

Thank you for that reply, i slightly understand what you are doing, but just tad hard for me to implement it to my form, as i am still learning lol. It is much apericiated for you taking your time in doing the code for me,

I have just thought if i can do it this way, where i have a text box which when i type the ID of that customer and press submit, it goes to MYSQL database gets the email and sends it.

Please note i have a datbase which gives id to every customer and has a section for email which is "EmailAD"

Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.