Hi,
I wrote this script in order to check for users that have their birthdate today and send them a Happy Birthday e-mail.
The problem is that it does check the users but is sending only to one, assuming that there are for example 5.
I think that the script is not checking for every user but only for one, or is checking every user but there need to be a loop for sending the e-mail to all that satisfy the criteria.
Any help would be great on debugging this.
Thanks
Here's the script:
<?
// Include configuration file
require ("config.inc.php");
require ("$lib/lib.php");
// Print top navigation
$page_code = "user";
$page_name = LANG_HEADERCONFIRM;
{
//Get today date
$tod = date("Y-m-d");
// Connect database
dbconnect();
// If confirmation completed, select user info
$sql = "SELECT email, name, surname, username, password, birthdate FROM $t_users
WHERE birthdate = '$tod'";
$result = @($sql)
or die ("Can not find user info.");
while ($row = mysql_fetch_array($result))
{
$co_email = $row['email'];
$c_name = $row['name'];
$c_surname = $row['surname'];
$c_username = $row['username'];
$c_password = $row['password'];
$c_birthdate = $row['birthdate'];
}
@mail($co_email, LANG_HAPBTHD,
"$tod,\n
".LANG_DEAR." $c_name $c_surname\n\n".LANG_MENSPARAB."
\n".LANG_MELCPTOS."
".LANG_EQUIP." $site_name", "From: $admin_mail");
}
?>