Jump to content

Comment Spam Filter


ShoeLace1291

Recommended Posts

Ok, so I want to make a comment spam filter for my site.  I know the basic logic, but have yet to figure out how to write the functions.  I have a database table called comments that has a column called "time", which contains a unix timestamp value of when it was posted.  Basically what I want to do is this:

 

When a user tries to post a comment, the script determines with a database query if they have posted a comment in the last 120 seconds.

 

So basically I have to find the current time, and the time it was 120 seconds before the current time.  Then I have to find any comments posted by the user that were made after the 120 second mark.

 

My database query should then look something like this, right?

 

$query = mysql_query("SELECT * FROM comments WHERE author = ".$_SESSION['id']." AND time > '".$120secondsago"'");

 

Please correct me if my logic is wrong, which it very well may be, but how would I find the unix timestamp code from 120 seconds before the current time?  Note that 120 seconds is just an example and also that I have not worked with dates in mysql very often.

 

$query = mysql_query("SELECT * FROM comments WHERE author = ".$_SESSION['id']." AND time

Link to comment
https://forums.phpfreaks.com/topic/214408-comment-spam-filter/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.