PHP Noob. How to write post to file?

I have a sample script here, why does this not work? What should I try?
When I open test.txt. there isn’t anything there

<?php header ('write post to file'); $handle = fopen("test.txt", "a"); foreach($_POST as $variable = $value) { fwrite($handle, "test"); fwrite($handle, $variable); fwrite($handle, "="); fwrite($handle, $value); fwrite($handle, "\r\n"); } fwrite($handle, "\r\n"); fclose($handle); exit; ?>

Learn first.

There are syntax errors in your code that are causing it to not function. And there are code tags to use to post code.

Sponsor our Newsletter | Privacy Policy | Terms of Service