I'm setting up landing page page and I want each user to be able to to only visit my index file only once without saving in SQL database, if opened again get redirected to main page.
I tried one script and modified it but doesn't seem to work or maybe I changed incorrectly.
$ip = $_SERVER['REMOTE_ADDR'];
$ipbreak = $_SERVER['REMOTE_ADDR'].PHP_EOL;
function donothing() {
;
}
if (strpos(file_get_contents("./ipblocker.txt"),$ip) == true) {
header("location: https://example.com/");
exit();
}elseif(strpos(file_get_contents("./ipblocker.txt"),$ip) == false) {
file_put_contents("ipblocker.txt",$ipbreak, FILE_APPEND);
donothing();
echo "LOADED";
}
I only want user to be able to view my landing page once only.