We help IT Professionals succeed at work.

Dump $_POST into a file or database

musickmann
musickmann asked
on
I'm using a PHP for a very large form. I have it generating a PDF file, but I want to dump all the entire POST array into a file or a database or something with no fomatting necessary, just something to use as a backup to make sure I'm capturing all the fields and such in the PDF. I'm not sure I'm asking the questiont he right way or not. I wasn't able to find something in the searches here.
 
Comment
Watch Question

Avinash ZalaWeb Expert

Commented:
You can create a temporary table and place the details in that table while you creating the PDF.

Hope this helps,
Addy
Commented:
You can do the following, you may need to create the dump.txt file first.
<?php
$fp = fopen('dump.txt', 'w');
fwrite($fp, print_r($_POST,true));
fclose($fp);
?>

Open in new window

musickmannData Analyst

Author

Commented:
That's exactly what I need. Thanks.

Would there be a benefit to serialize that output?

Commented:
If you want to convert it back to an array afterwards serialize it. If you only want to read it, I wouldn't.
musickmannData Analyst

Author

Commented:
Perfect. Thanks. Since I may need to reprocess the array once I fix the fpdf part I will serialize. Just what I needed to know.