How do you rename a textfile with a datetime stamp in php?
<p>I'm new to php and programming in general, so forgive my ignorance on this one.  I am trying to rename a textfile I created with a datetime stamp, and can't seem to get it right.  I am writing info to a textfile after someone submits data, and that works, but I need to make every text file unique, so I need a unique naming convention.  I even tried using the first name of the entry, but I can't get that to work either.  Here's what I have so far:</p>

<pre><code>&lt;?php
$FirstName = $_POST["fname"].PHP_EOL;
$LastName = $_POST["lname"].PHP_EOL;
$Address = $_POST["address"].PHP_EOL; 
$City = $_POST["city"].PHP_EOL; 
$State = $_POST["st"].PHP_EOL; 
$Zip = $_POST["zip"].PHP_EOL; 
$Tel = $_POST["tel"].PHP_EOL; 

$AddressFile = "Address_Entries.txt";
$ourFileHandle = fopen($AddressFile, "a") or die("can't open file");

$date = new DateTime();
echo $date-&gt;format('Y-m-d H:i:sP') . "\n";

fwrite($ourFileHandle, $FirstName);
fwrite($ourFileHandle, $LastName);
fwrite($ourFileHandle, $Address);
fwrite($ourFileHandle, $City);
fwrite($ourFileHandle, $State);
fwrite($ourFileHandle, $Zip);
fwrite($ourFileHandle, $Tel);
fclose($ourFileHandle);
echo "&lt;p&gt;File has been writtten to successfully!&lt;/p&gt;";

rename("C:/xampp/security/htdocs/testes/Address_Entries.txt", $FirstName);
?&gt;
</code></pre>

<p>Any help is appreciated.  Thanks!</p>

<ul>
<li>A</li>
</ul>
