Hello Everyone,
My mailer keeps sending duplicates & I can't find the problem in my code. I would appreciate it if someone could look it over & point out the problem.
<?
if($action == "mail") {
$success=0;
$failed=0;
$headers .= "From: Golden Planet Clubs PTC Admin <admin@ptc.goldenplanetclub.com>\n";
$headers .= "Reply-To: <admin@ptc.goldenplanetclub.com>\n";
$headers .= "X-Sender: <News@ptc.goldenplanetclub.com>\n";
$headers .= "X-Mailer: PHP4\n"; //mailer
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <admin@ptc.goldenplanetclub.com>\n";
$subject = stripslashes($subject);
$msg = stripslashes($msg);
echo "Your message is being sent!<br><br><table>";
$sql=$Db1->query("SELECT * FROM user");
while($userinfo=$Db1->fetch_array($sql)) {
$to=$userinfo['email'];
if(@mail($to,$subject,$msg,$headers)) {
$result="<font color=\"darkgreen\">Success!</font>";
$success++;
}
else {
$result="<font color=\"darkred\">Failed!</font>";
$failed++;
}
echo "<tr><td>$to</td><td>$result</td></tr> ";
flush();
}
echo "</table>";
$Db1->sql_close();
$includes[content] = "
<script>
if(confirm('Failed: $failed | Successes: $success')) {
location.href='index.php?view=admin&ac=stats';
}
</script>";
}
else {
$includes[content]="
<div align=\"center\">
<form action=\"index.php?view=admin&ac=mailer&action=mail&s=$s\" method=\"post\">
<table cellspacing=\"0\" cellpadding=\"0\" border=0 bgcolor=\"#C6DAE2\" width=\"100%\">
<tr>
<td>
<table cellspacing=\"1\" cellpadding=\"5\" border=0 width=\"100%\">
<tr bgcolor=\"#F1F6F7\">
<td valign=\"top\" width=\"100%\">Subject:</td>
<td><input type=\"text\" name=\"subject\" size=\"35\"></td>
</tr>
<tr bgcolor=\"#F1F6F7\">
<td valign=\"top\">Message:</td>
<td><textarea cols=50 rows=13 name=\"msg\"></textarea></td>
</tr>
<tr bgcolor=\"#F1F6F7\">
<td colspan=3 align=\"center\"><input type=\"submit\" value=\"Mail Them Now\"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>
";
}
?>
Thanks,
Joseph.