question regarding "mass mailer"
Posted: Mon Sep 25, 2006 5:55 pm
I've been on and off with php for a few years and recently, i've made the jump back into web development so excuse my noobie code 
heres the situation.. im helping my teacher create a site for some club of hers (big school club) and we have registrations with usernames/emails adn stuff like that. I'm kinda stuck with a mass mailer script right now (to send members announcements).
Here is the entire form processing file
What we're interested in is the part that starts with
We plan to have all the users stored in a table with a field for email. What i get from this script so far is that it doesn't cycle through the list of emails? is my syntax for the while loop wrong?
heres the situation.. im helping my teacher create a site for some club of hers (big school club) and we have registrations with usernames/emails adn stuff like that. I'm kinda stuck with a mass mailer script right now (to send members announcements).
Here is the entire form processing file
Code: Select all
<?php require_once('Connections/database1.php'); ?>
<?php
mysql_select_db($database_database1, $database1);
$query_emails = "SELECT email FROM users";
$emails = mysql_query($query_emails, $database1) or die(mysql_error());
$totalRows_emails = mysql_num_rows($emails);
$source = $_GET['type'];
if(isset($source)) {
if($source == email)
{
session_start();
$headers = 'From: admin@iced-flame.net' . "\r\n" .
'Reply-To: admin@iced-flame.net' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($_POST['emailto'], $_POST['subject'], $_POST['message'], $headers);
echo("Mail sent");
die();
}
if($source == massemail)
{
$headers = 'From: admin@iced-flame.net' . "\r\n" .
'Reply-To: admin@iced-flame.net' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
while ($row_emails = mysql_fetch_assoc($email)) {
mail($row_emails['email'], $_POST['subject'], $_POST['message'], $headers);
}
echo("Mail sent to members");
die();
}
else {
echo ("Invalid source.");
die();
}
} else {
echo ("No source specified.");
die();
}
mysql_free_result($emails);
?>Code: Select all
if($source == massemail)