So I'm trying to block voting for 24hours after a user has already voted, and I've been stuck for a while now. I tried working off this earlier post but I haven't had any luck. I was able to echo the ip address but not the vote_time
I have a database with a table named voterlist that has two columns: submission_ip and vote_time. (the time is formatted like this date("Y-m-d H:i:s",time())
)
My php looks like this:
<?php
$ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);
$query = "SELECT vote_time FROM voterlist WHERE submission_ip ='$ip'";
$result = mysql_query($query);
if(mysql_num_rows($result) < date('Y-m-d H:i:s',strtotime('-24 hour'))) {
echo 'you can vote again in 24 hours';
}else {
echo 'vote now';
}
?>
Any help with this query would be greatly appreciated.