Hello all,
I have been working on trying to store a user's ip address, then when they return and login it shows them their last used ip. The login function itself stores the ip to a file, and the control panel they are forwarded to displays the last ip and the current ip used.
The problem I am having is that because the login process itself sets the last used ip, the current and last used ips are always the same. What is a way to properly do this? I am totally new to php so myql seems a little far fetched at this point.
Here is how it sets the ip to the file
//Begin last used ip storage
$lastipfile="logs/" . $username . "_lastip.txt";
file_put_contents($lastipfile, $REMOTE_ADDR);
Here is where it reads it from the file
<?php
$lastipfile="../logs/" . $username . "_lastip.txt";
If(file_get_contents($lastipfile)==False)
{
echo"This is your first visit, no other ips have been logged.";
}
else
{
$yourip=file_get_contents($lastipfile);
echo"$yourip <br><br>";
}
echo"Current Ip: $REMOTE_ADDR <br>";
?>
Any Ideas on how to accomplish this would be greatly appreciated.
Thanks in advance.