Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website Design Forum


You are currently viewing our Website Design Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-11-2007, 01:03 PM Flood Control - Php
Junior Talker

Posts: 18
Trades: 0
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.
James` is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-11-2007, 01:39 PM
GeorgeB
Guest

Posts: n/a
Trades:
Had a look at your tutorial.

It's nice solid logic until you get to the date part. It assumes everyone is using the same date format in their script and inputs it into the database that way.
Reply With Quote
 
Old 01-11-2007, 02:02 PM
Junior Talker

Posts: 18
Trades: 0
Thanks
James` is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Flood Control - Php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14136 seconds with 12 queries