Uber simple example to illustrate the point:
$message = $_POST[\'message\'];
$fp = fopen(\"log.txt\", \"a\");
fwrite($fp, $message);
fclose($fp);
>
Depending on your use case, you may want to flock() the log file, to prevent multiple parallel requests from mixing up in your file:
$logtext = sanitizeLog($_POST[Message']); $fd = fopen( "/path/to/log.txt", "a"); if(flock($fd, LOCK_EX)) { fseek($fd, 0, SEEK_END); fwrite($fd, $logtext); flock($fd, LOCK_UN); } fclose($fd);
I've omitted checks for fopen() results...