How to save a POST request to a file

I’ll give a couple of examples of saving the data of the incoming POST request to a file:

Option 1

$s = implode('|', $_POST);
exec('echo $s >> file.txt');

Option 2

file_put_contents('file.txt', json_encode($_POST));

Example of option 2 with a specific parameter:

file_put_contents('file.txt', json_encode($_POST['parameter']));

Leave a comment

Leave a Reply

Discover more from IT Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading