I made a voting script, where when you click a link to vote for a certain field, it sets a vote variable to the ID number of the field, and then submits the vote. The actual voting works, but I am trying to make it so it logs the IPs, and then sets a "time" column to 1 until 24 hours later, making it so all IPs with the variable 1 cannot vote, here is my code:
if ($vote != ""){
$ip = getenv('REMOTE_ADDR');
if ($getip=mysql_query("SELECT time FROM ip_logs WHERE ip=$ip"))
{
if ($getip['time']==1){
$voterip = 1;
}
if ($getip['time']==0){
mysql_query ("UPDATE top_requests SET requests=requests+1 WHERE ID=$vote", $db);
}
}
else {
mysql_query ("INSERT INTO ip_logs (ip,time) VALUES ('$ip', 1)", $db);
mysql_query ("UPDATE top_requests SET requests=requests+1 WHERE ID=$vote", $db);
}
}
When my IP is logged, and I try voting again, it logs my IP each time but doesnt find the IP thats already there, it just keeps letting me vote over and over and my IP gets logged many different times. Can anyone help me by telling me whats wrong with my code?