I have a website that every time a user login or logout I will save it to a text file.
my code doesn't work in appending the data or creates a text file if does not exist.. here is the sample code
$myfile = fopen("logs.txt", "wr") or die("Unable to open file!");
$txt = "user id date";
Try something like this :
$txt = "user id date"; $myfile = file_put_contents('logs.txt', $txt.PHP_EOL , FILE_APPEND | LOCK_EX);