For this tutorial, you need a host that supports PHP and MySQL. Note: this tutorial may not be suitable for beginners, you MUST have some knowledge of MySQL and PHP.
If you've written your own commenting script or did it following a tutorial,you may have had problems with comment flooding. Here's a way to add Flood Control to your Content Mangement System.
First, log into your phpMyAdmin and open your comments table and run the following query:
Quote:
|
ALTER TABLE table ADD ip VARCHAR(20);
|
Okay, we're done with that. Now into the coding. Remember you must combine this with your commenting script.
Quote:
<?php
// Database connection here
$query="SELECT * FROM table where ip='$ip' and date > CURDATE() - INTERVAL 5 MINUTE ";
$result= mysql_query($query) or die ("Could not execute query : $query." . mysql_error());
if (mysql_num_rows($result) == '0') {
// Insert your comments adding query and everything else here
} else {
echo "You're not allowed to post so soon after your last comment.";
}
?>
|
Remember to change table with your actual table name and date, if your date field has another name.
If you didn't have an ip field before, you will need to edit your comments adding query and add the IP thing. You will need to edit your comments form too, add this:
Quote:
<input type="hidden" name="ip" value="<?php $visitorip = $_SERVER['REMOTE_ADDR'];
echo "$visitorip"; ?>" />
|
I know it's confusing, but if you have any questions feel free to post them. 
|