How to block spam posts in your online forum

Most of you who own an online forum have already known much about spammers are trying to add bad posts, posts of links to porn websites, links to drugs, etc. I’m so tired of those who don’t respect my forum. So today, I’m gonna give you an instruction who to restrict those posts from entering to your professional forums. Since I added this logic in my online forum, I never see any bad post in the database any more.

Go to your forum root directory, pick the file called posting.php. First of all, you got to create a table of credible users in your database, example table is named tbl_users. The fields include just id (required), username (required), date_joined (optional). That’s all you need. Then copy my codes below and paste them to line 28 of your posting.php file. Remember to change the table “tbl_users” to the user table name in your database. The codes below will display a message and exit when there’s a user trying to post bad post to your forum. It only allows users who are credible (real users) in your tbl_users table.

$aw_id = 0;
$getuser = $user->data[‘username’];
// check this username if it matches the username in separate member database to prevent hackers who post junks to your forums

$sql = “SELECT User_ID
FROM member_database.tbl_users
WHERE User_Name = ‘$getuser'”;

$result = $db->sql_query($sql);
$this_data = $db->sql_fetchrow($result);

$aw_id = $this_data[‘User_ID’];
if($aw_id == ” || $aw_id == 0){
$box_t = ‘<div align=”center” style=”margin-top:50px;”><table cellpadding=”20″ style=”border:5px #027ab7 solid; background: #ecf3f7;”><tr><td>’;
$box_b = ‘</td></tr></table></div>’;
$message = ‘Our forum is only for licensed users. Please login to <a href=””></a> and click on Forum icon to start posting a reply or a new topic.’;


The logic above has been tested on Windows and Linux servers. If you have issue implementing my codes, please call me at 1-415-845-0248 (Binh) I will help you after my working hours.