Forum Moderators: coopster

Message Too Old, No Replies

Stopping flooding / spam

         

smatts9

11:10 pm on Mar 8, 2006 (gmt 0)

10+ Year Member



I have a form that insert's data into a mysql table. I record the users, ip and time of submission. I use now(), when inserting the time into the table. I was wondering if there is a way to not allow them to submit anymore until an hour after their previous submission? If there is a better way to log the time to make it easier, please tell, any advice would help.

jezra

12:49 am on Mar 9, 2006 (gmt 0)

10+ Year Member



I usually store my times as integers set to the current unix time which is the number of second since the unix epoch. By measuring time in seconds from a common reference, I will always be able to discern time that has past by subtracting one time from another.
for example.
$now = time();
$seconds_that_have_passed = $now - $time_retrieved_from_db;
if($seconds_that_have_passed<3600)
{
//less than one hour has passed
echo "forget it Bub. Only one post per hour";
}