Each time a page is viewed, check to see if the IP address is in the database table after deleting records that are longer than 24 hours.
// Purge records mysql_query("DELETE FROM ip_table WHERE access_date < DATE_SUB(CURDATE(), INTERVAL 24 HOUR)"); $ip = $_SERVER['REMOTE_ADDR']; $result = mysql_query("SELECT ip FROM ip_table WHERE ip = '$ip'"); if($result){ die("You can access this again in 24 hours"); } else { $result = mysql_query("INSERT INTO ip_table (ip, access_date) VALUES ('$ip', NOW())"); }
However, this will block all users using the shared connection. It is better to require a login, and then block access for each user.
source share