I’ve only recently begun working with databases, and my knowledge for processing forms is limited to this. So far, I’ve created a form that selects a group of recipients for a newsletter, and stores them in a $get variable according to the selection.
I’m hoping someone nice enough will help me figure out how to send individual emails to the selected recipients when the form is submitted.
First, here’s part of the form, for reference:
Mailing List
SEND TO:checked = "checked" <?php } ?>/> Austin Area
checked = "checked" <?php } ?> /> DFW Area
Second, here’s WHAT PERTAINS to the script i need help with. If something unrelated is missing, don’t worry, I’ve tested the form, and it processes fine. Just need help with the indicated areas below. THANKS IN ADVANCE!:
[php]
if (array_key_exists(‘send’,$_POST)) {
//Setup database variables
if ($location ==“ATX”) {
$get = mysql_query(“SELECT * FROM E_list WHERE status = ‘activated’ AND location=‘ATX’”);
}
if ($location ==“DFW”) {
$get= mysql_query(“SELECT * FROM E_list WHERE status = ‘activated’ AND location=‘DFW’”);
}
if ($location ==“ATX,DFW”) {
$get = mysql_query(“SELECT * FROM E_list WHERE status = ‘activated’”);
}
$additionalHeaders = “From: veeps [email protected]\r\n”;
$subject = ‘Veeps News’;
if ($_POST && empty($missing)) {
//create email
$body = “ADD TEXT HERE, AND CONCATENATE MORE LATER”;
//loop through results
for ($x=0; $x<count($_POST); $x++) {
if( //criteria help needed here)
{
$to = //value per criteria above
}// end if
} //end for loop
$mailSent = mail($to, $subject, $body, $additionalHeaders);
}
}
?>
[/php]