UBB.Dev
Posted By: jlory Email moderators when new posts and reply - 09/04/2002 2:55 PM
I wrote a little script that sends an e-mail to all moderators when anyone adds or replies to a post. I put it right after the two "INSERT" lines on addpost.php. I realize this may not work on all systems but it seems to do the trick for me:


<?
/* E-mail board moderators to let them know about the post. */
$connection = mysql_connect("localhost","root", "connect") or die("ConnectFailed");
$db = mysql_select_db("ubb_threads", $connection) or die("SelectFailed");
$sql = "SELECT * FROM w3t_Moderators where Mod_Board = "$Board"";
$sql_result = mysql_query($sql, $connection);
while ($row = mysql_fetch_array($sql_result)){
$username = $row["Mod_Username"];
$sql2 = "SELECT * FROM w3t_Users where U_Username = "$username"";
$sql_result2 = mysql_query($sql2, $connection);
$row2 = mysql_fetch_array($sql_result2);
$email_address = $row2["U_Email"];
$mailto = $email_address;
$mailsubject = "UBB Threads Forum Post";
$mailheaders = "FROM: [][email protected]";[/]
$mailbody = "
You have a new post to your UBB Threads forum.
Please check your forum to approve this post:
From: $postername
Subject: $FormSubject
Body: $FormBody
Click here to view UBB Threads forums: http://myserversurl/www/ubb_threads/ubbthreads.php
";
mail($mailto, $mailsubject, $mailbody, $mailheaders);
}
?>
Thank you
© UBB.Developers