I have a list of emails and I want to email only selected people by clicking on a checkbox next to their record.
So I created a nice table that shows all records and a checkbox next to each record with the recordID as the value.
But, I am not sure where to go from here. The next page has the mail() function, but I don't know what to do next.
here's the code on page 1:
<form name="form1" method="post" action="mail-to-some.php">
<tr>
<td class="nicetableheader">REQUESTOR</td>
<td class="nicetableheader">NAME</td>
<td class="nicetableheader">checkbox</td>
</tr>
<?
while ($row = mysql_fetch_array($sql)) {
$recID = $row['recID'];
$name = $row['name'];
?>
<tr>
<td class="nicetablerow"><?php echo $name; ?></td>
<td class="nicetablerow" align="center"><input name="sendto" type="checkbox" value="<? echo $recID; ?>" /></td>
</tr>
<? } ?>
[COLOR=DarkGreen]<tr>
<td colspan="16" align="right">[/COLOR][COLOR=DarkOrange]<input class="textbox" type="submit" name="Submit" value="Submit">[/COLOR] [COLOR=DarkGreen]</td>
</tr> [/COLOR]
</form>
And here's the attempted code on the mail-to-some.php. I am having alot of problems about how to make the query from the db - depending on what records were chosen from the previous page.
include('includes/configure.php');
$sql = mysql_query(" ? ");
while ($row = mysql_fetch_array($sql)) {
$email = $row['email'];
$to = $email;
$mailheaders = "Attention!\n";
$Subject = "My subject";
$msg = "My message\r\n";
mail($to, $Subject, $msg, "From: IT Help Desk", $mailheaders);
}
If I am completely off my rocker on how this is performed correctly, I won't be surprised. but any help will be appreciated!