Hello,
I have this code:
<?php
$dateTime = date('Y/m/d G:i:s');
$fp = fopen('log.txt', 'r+');
if(!$fp){
echo "Log file doesn't exists.";
}
else{
$visited = FALSE;
while (!feof($fp))
{
$buffer = fgets($fp);
list ($ip, $time) = split(' ', $buffer);
//Checks if IP is already logged.
if ($_SERVER['REMOTE_ADDR'] == trim($ip)){
$visited = TRUE;
echo "Not your first visit.";
}
}
if (!$visited){
fwrite($fp, $_SERVER['REMOTE_ADDR']. " $dateTime\n");
echo "First visit.";
}
fclose($fp);
}
?>
This log ip of visitors, and if is first visit will show us "First visit.", if is not the first visit will show us "Not your first visit."
Now I want to do some modifications to this code, I want to redirect visitors if is not the first visit, and if is the first visit to show a newsletter.html page
I think is simple, but I'm not a PHP coder and I don't know how to do it.
Thanks in advance for help.