Click to See Complete Forum and Search --> : FOpen


Anon
01-31-2002, 10:09 PM
I read the PHP manual on fopen and other filesystem functions but I'm not udnerstanding the concept well enough. I was wondering if someone could help me with an example. I want to take the contents of 2 variables from a form (say $fname and $lname) and put them in a text file that I create delimited with pipes. So if I entered Louis as fname and Smith as lname, it would create a file (lets call it db.txt) and would insert "Louis | Smith" into the file. Then, I want to delete the file. Any ideas on how to do this? I really appreciate any help!

leifr
02-03-2002, 11:17 AM
Hi,

Look at this:
<?php
$FileHandler = fopen("db.txt", "w"); // create file, if file exists open it
fwrite($FileHandler, $fname." | ".$lname); // write names to file
fclose($FileHandler); // close file

unlink("db.txt"); // delete file
?>

I hope this helps ;-)

LeifR