$timeNow = time();
$timeExpire = $timeNow + 10;
$User = $con->query("SELECT * FROM players WHERE Username='".$_SESSION['Username']."'");
$UserInfo = $User->fetch_object();
if($timeNow >= $UserInfo->TimeExpire) {
echo "Wood Gathered";
$con->query("UPDATE players SET Wood = Wood+5 WHERE Username='".$_SESSION['Username']."'");
$con->query("UPDATE players SET Time = '".$timeNow."' WHERE Username='".$_SESSION['Username']."'");
$con->query("UPDATE players SET TimeExpire = '".$timeExpire."' WHERE Username='".$_SESSION['Username']."'");
}
How can I make the following code work even the user is not logged in?
Like for example he comes back in 1 day and gets 1728 wood because 86400 (1 day) / 50 (get resources every 50 seconds) is equal to 1728.