Hello I have this voting script attached it counts votes by IP address. Please how can I create a kind of time session on the IP addresses. \"say 5 votes a day per IP.
the easiest way to limit the number of votes per time frame it to store a time-stamp when the person votes in your voting_ip table... then the next time they vote, count all records in your voting table with the persons Id whose time-stamp is greater than the (current time - 24 hours). if the count is >=5 votes.. display the message saying you already votes. its should just be a simple modification to your existing code.
your select should be modified to something like this:
SELECT ip_add FROM voting_ip
WHERE mes_id_fk='$id' AND ip_add='$ip' AND timetamp>'$nowMinus24Hours'
and your insert should be something like
INSERT INTO voting_ip (mes_id_fk,ip_add,timestamp) values ('$id','$ip','$now')
$now can be set in php using something like:
$timestamp = new DateTime();
$now=$timestamp->format('Y-m-d H:i:s');
and then $nowMinus24Hours is just a variable = $now minus the 24 hours.
NOTE: you can do a SELECT Count(ip_add).... or Select count(*) (Select ..) to get the number of records as the result of your query.