The string below runs as a maintenance script on one of my sites and at the moment it emails anyone who's plan has expired (which is fine) but it also emails people who haven't selected a plan yet because the value is less than today. I was wondering if someone could help tweak the code so it only emails the people who's plans have actually expired only???
Here's the script.
<?include_once "index.php";
$EXday = date('d', mktime(0,0,0,0, date(d) + 0, 0));
$EXmonth = date('m', mktime(0,0,0, date(m), date(d) + 0, 0));
$EXyear = date('Y', mktime(0,0,0,date(m) ,date(d) + 0, date(Y)));
$todays_date = "$EXmonth/$EXday/$EXyear";
$today = strtotime($todays_date);
$aq = mysql_query("SELECT * FROM jobs order by jobid asc");
while($bq = mysql_fetch_array( $aq ))
$az = mysql_query("SELECT * FROM employers order by employerid asc");
while($bz = mysql_fetch_array( $az ))
{
$expiry3 = strtotime($bz[expiry]);
if ($expiry3 < $today)
{
$message = file_get_contents($basedir . $slash . "../lang/$a18[lang]/emails/employers/plan_expired.txt");
$subject = "Your employer plan at $a18[sitename] has expired";
$message = str_replace("[[[sitename]]]", $a18[sitename], $message);
$message = str_replace("[[[fullurl]]]", $fullurl, $message);
$message = str_replace("[[[contactname]]]", $bz[contactname], $message);
$message = str_replace("[[[plan]]]", $bz[plan], $message);
$message = str_replace("[[[EXmonth]]]", $EXmonth, $message);
$message = str_replace("[[[EXday]]]", $EXday, $message);
$message = str_replace("[[[EXyear]]]", $EXyear, $message);
$message = str_replace("[[[footer]]]", $a18[footer], $message);
$message = str_replace("[[[contactemail]]]", $a18[mailfromemail], $message);
$from = "From: $a18[mailfromemail]";
mail ($bz[ename], $subject, $message, $from);
$fis = "update employers set
plan = \"\",
expiry = \"\",
resume = \"No\",
resumenum = \"\",
posting = \"No\",
featured = \"No\",
homepage = \"No\",
posts = \"\",
paid = \"0\"
where employerid = \"$bz[employerid]\"";
$rfis = mysql_query($fis) or die(mysql_error());
}
}