1$log_content="This line is logged on 2020-08-14 09:55:00";
2$myfile = fopen("log.txt", "a") or die("Unable to open file!");
3fwrite($myfile, $log_content);
4fclose($myfile);
1//Something to write to txt log
2$log = "User: ".$_SERVER['REMOTE_ADDR'].' - '.date("F j, Y, g:i a").PHP_EOL.
3 "Attempt: ".($result[0]['success']=='1'?'Success':'Failed').PHP_EOL.
4 "User: ".$username.PHP_EOL.
5 "-------------------------".PHP_EOL;
6//Save string to log, use FILE_APPEND to append.
7file_put_contents('./log_'.date("j.n.Y").'.log', $log, FILE_APPEND);
8