stop forum flooding

Posted on 2008-10-24
Last Modified: 2012-05-05
ok i have been having problems with people flooding my forum... any suggestions how i could stop this?
(i have shortend down my reply script)
<table width="70%" class='maintables'>

<tr class='headline'><td>Reply</td></tr>

	<tr class='maintables'>

		<td align="center">



			if(isset($_POST['submit'])) {




				if(strlen($yourpost)<1) {

					print "You did not type in a post."; //no post entered


					$thedate=date("U"); //get unix timestamp

					$displaytime = time();

					//we now strip HTML injections



					//This is where the bbcode come in.

					$message = new BBCode;

					$message->selection = $yourpost;

					$message->parseCode(); // set to 1 if you want to disable bbcode


					$yourpost = $message->parsed;

					$insertpost="INSERT INTO `forumtutorial_posts` (`author`,`forum`,`title`,`post`,`showtime`,`realtime`,`lastposter`,`parentid`) values('$name','$forum','$subject','$yourpost','$thedate','$thedate','$name','$id')";

					mysql_query($insertpost) or die("Could not insert post"); //insert post

					$updatepost="UPDATE `forumtutorial_posts` SET `numreplies`=`numreplies`+'1', `lastposter`='$name', `lastrepliedto`='$thedate' WHERE `postid`='$id'";

					mysql_query($updatepost) or die("Could not update post");

                                  $updatep="UPDATE `users` SET `post_count`=`post_count`+'1' WHERE `Username`='$name'";

					mysql_query($updatep) or die("Could not update post");

					print "Message posted, go back to <A href='index.php?page=message&id=$id&forum=$forum'>Message</a>.";



				$gettopic="SELECT * FROM `forumtutorial_posts` WHERE `postid`='$id'";

				$gettopic2=mysql_query($gettopic) or die("Could not get topic");






                <?php  if($gettopic3['forumlock'] == 0)


     ?> Your message:





                    <br><form action='index.php?page=reply&forum=<? echo $forum; ?>&id=<? echo $_GET['id']; ?>' method='post' name='myform'>

					  <div style='padding-left: 5px; padding-top:5px;'></div>

					  <input name="title" type="hidden" value="<?php echo $gettopic3['title'];?>" />

				      <textarea id="inputforum" class="inputforum" name='yourpost' rows='5' cols='40'><?php if(isset($_POST['quote'])) {

                        $quote= $_POST['quote'];

						   $query = "SELECT * FROM forumtutorial_posts where postid=$quote"; 

if ($result = mysql_query($query)){

    if (mysql_num_rows($result)) {

        $array = mysql_fetch_assoc($result);}


?> quote by:<?php echo $array['author'];?>


echo $array['post']; }}?> [/quote]</textarea>


				      <input type='submit'class="submit-btn" name='submit' value=''>






    echo 'forum is locked';






			?>		</td>




$pagenum = isset($_GET['pagenum']) ? $_GET['pagenum'] : "1";

$gettopic="SELECT * from forumtutorial_posts where postid='$id'";

$gettopic2=mysql_query($gettopic) or die("Could not get topic");




//Here we count the number of results

//Edit $data to be your query

$data = mysql_query("SELECT * from forumtutorial_posts where parentid='$id'") or die(mysql_error());

$rows = mysql_num_rows($data);

//This is the number of results displayed per page

$page_rows = 4;

//This sets the range to display in our query

$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;

//This is your query again, the same one... the only difference is we add $max into it








Open in new window

Question by:runnerjp
1 Comment
LVL 31

Accepted Solution

Frosty555 earned 500 total points
ID: 22797192
Every time the user makes a post, update their user profile (e.g. whatever table you are using to store user information) to store the date/time of the last post.

Next time a user tries to post, first check how long it has been between the current date, and the last post date. If less than a minute or so has elapsed, fail with a validation error telling the user to wait. Only allow posts after a certain amount of time has elapsed.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now