I have an checkbox on my Add Page, which the users are supposed to check if the post is "high priority".
Now everytime a post is marked as such, I would like an email to be sent out.
The code below is what I have on my event add page.
The first time I tried it, it worked. What I quickly noticed though, is once one post was marked "high priority" (checkbox=1), then an email would go out with every post, reguardless of what the checkbox was, so long as that one high priority existed.
So it appears as long as there is one entry for high priority in the database at all, this code will trigger the email. How can I make this specific to just the current entry, so an email would only go out with every post marked with a high priority?
function AfterAdd()
{
//********** Check if specific record exists ************
global $conn;
$strSQLExists = "select * from `_Master Reports` where `High Priority`='1'";
$rsExists = db_query($strSQLExists,$conn);
$data=db_fetch_array($rsExists);
if($data)
{
// if record exists do something
// ********** Send email ************
mail('****@****.com', 'a HIGH PRIORITY report has been posted',
'A report marked as High Priority has been posted',
"To: Mr. ***** <****@****.com>\n" .
"From: Mr. ***** <****@****.com>\n" .
"MIME-Version: 1.0\n" .
"Content-type: text/html; charset=iso-8859-1");
}
else
{
// if dont exist do something else
}
}
Any help would be greatly appreciated! Thanks all!