Save form data in a txt file with current date in file name
I use the following script to save the data from a form to a txt file on the server with the name file_name.txt. What i would like is for the file name to be the date and time the file was posted in UTC eg. 2009-06-09-13-45-59.txt (year-month-day-hour-minute-second.txt)
PHP Code:
<?php
// retrieve form data
$input = $_POST['msg'];
// Open the file and erase the contents if any
$fp = fopen("file_name.txt", "r+");
// Write the data to the file
fwrite($fp, $input).' ';
// Close the file
fclose($fp);
?>