-
Admin Send
how do I get this to send to all people on my sql database!!
PHP Code:
<?php
mysql_connect (localhost, user, pass);
mysql_select_db (nz);
if ($action == "save")
{
$result = mysql_query ("SELECT name, email, id FROM warriors_note ord id");
$to = "$email";
$subject = "Warriors Supporters Site Membership";
$body = "$name";
$headers = "From: Warriors.Rleague.Com<mailto:[email protected]>\n";
$headers .= "From: Feedback \n";
$headers .= "X-Sender: <[email protected]>\n";
$headers .= "X-Mailer: PHP\n"; // mailer
$headers .= "Return-Path: <[email protected]>\n"; //
$message = "Hi $name, thanks for registering your interest with our site. We will let you know once the site has opened for full memberships.";
$message .= "\n\n";
mail($to,$subject,$message,$headers);
echo "Sent!";
}else{
?>
<form method="POST" action="noteadmin.php?action=save">
<input type="hidden" name="action" value="save"/>
<p>Subject:<input type="name" name="suibject" size="20"></p>
<p>Body:<textarea rows="10" name="body" cols="50"></textarea>
</p>
</p>
<input type="submit" value="Register" name="B1"></
</form>
<?php
}
?>
-
You need to obtain a recordset of all the users in your table and send an e-mail separatley to each one.
PHP Code:
<?php
@mysql_connect (localhost, user, pass) or die('Error connecting');
@mysql_select_db (nz) or die ('database error');
($result = @mysql_query ("SELECT name, email FROM warriors_note;")) or
die ('query error');
/* loop through each row and send the e-mail */
while ($row = mysql_fetch_assoc ($result) {
$to = "{$row['name']} <{$row['email']}>";
$subject = "Subject goes here";
$headers = "custom: headers\n"
$message = "Put message here";
$message .= "\n\n";
mail($to,$subject,$message,$headers);
}
?>