Hi,
Is it possible to create a piece of code which will get the users IP address and store it in a TXT file or on a database. If the user visits the page again the script will look at their IP address and if they have already visited the page before today then they will be redirect on a another page which will say an error.
If you need any more information please ask.


Hello Amarildo, This is most
Hello Amarildo,
This is most easily done using a cookie. You could add the following PHP code to the top of any page, and if the person has already viewed that page in the last 24 hours they will be redirected to your /error.php page:
<?phpif ($_COOKIE[$_SERVER["REQUEST_URI"]])
{
header("Location: /error.php");
exit();
}
setcookie($_SERVER["REQUEST_URI"],1,strtotime("+1 day"),"/");
?>
Hope this helps!
Cheers,
David.
Hi thanks for your reply, If
Hi thanks for your reply,
If the user has not visited the page before they get sent to another page.
Is it possible to change the timing to say 5 hours etc?
Sure, in place
Sure, in place of
strtotime("+1 day")
you could use:
strtotime("+5 hours")
The strtotime() function supports almost any natural language period description - check out the following page for more info:
http://php.net/manual/en/function.strtotime.php
Cheers,
David.