How to restrict votes per day by IP in Php+Mysql voting?

前端 未结 3 1473
醉梦人生
醉梦人生 2021-01-29 02:23

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.

3条回答
  •  迷失自我
    2021-01-29 02:48

    you can add a timestamp column in 'voting_ip' table and set no unique keys.

    then you can do the query to get last 5 records.

    just subtract the time by latest record and last record

    for example:

    $times=mysqli_query($bd, "SELECT timestamp FROM voting_ip WHERE mes_id_fk='$id' AND ip_add='$ip' order by timestamp desc limit 5");
    
    if(mysqli_num_rows($ip_sql) < 5 || {first record - last record < 24 hours})
    ...your codes...
    

提交回复
热议问题