I would like to limit the access of a function i've created to once every 24 hour based on the users IP address. I would also like the PHP script to delete the MySQL record if it's older than 24 hours.
If the user already has used the function within 24 hours, show them a message and prevent the script from continue running.
If the user already has used the function but 24 hours has passed since he used the function, delete the MySQL record and let the script continue running.
<?php $ip = $_SERVER['REMOTE_ADDR']; $con=mysqli_connect("domain.com.mysql","domain_com","domain_password","domain_database"); $result = mysqli_query($con,"SELECT * FROM ipblock WHERE ip='".$ip."'"); while($row = mysqli_fetch_array($result)); if($ip == $row['ip']) //and code for checking how old the record is { // The user has used the function within 24 hours, kill the script. echo "Come back in 24 hours"; exit; } else { // Looks clear, let them use the function $MyFunction = true; } ?>
I'm lost and as you can see i am also missing some statements for deleting old records (-24 hours)..
Could anyone provide me with an example of how to do this? Thanks