Skip to content

Instantly share code, notes, and snippets.

@derak-kilgo
Created February 24, 2022 22:10
Show Gist options
  • Save derak-kilgo/7b67e0582ab53c4c88bcc2b12fccd8dd to your computer and use it in GitHub Desktop.
Save derak-kilgo/7b67e0582ab53c4c88bcc2b12fccd8dd to your computer and use it in GitHub Desktop.
post2log - tool to debug anything that sends data via POST request with php
<?php
$file = __DIR__ . DIRECTORY_SEPARATOR . 'post2log.txt';
$post = $_POST;
if(!empty($post)){
$post['timestamp'] = date('r');
file_put_contents($file,print_r($post,true),FILE_APPEND);
http_response_code(202);
print_r($post);
}else{
http_response_code(405);
echo "This endpoint only accepts post requests";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment