I am using a simple TXT based chat posting utitlity and would like to add a clear button so that i can clear the TXT file of it's contents. Any ideas?
You could always delete it and recreate it.
Use unlink to remove the file then $text=""; $filename=""; $newfile=fopen("/path/$filename","w"); fwrite($newfile,$text); fclose($newfile);
Hope that sort of helps
Darren http://www.php4hosting.com/
I have a suggestion...
Try using
unlink($file); touch($file);
instead, as it first deletes the file, then creates a new, empty file. Faster, and easier to read.
-Chris Simmons
The reasoning behind my method was so that you can write data that may need to be contained within the file. If the file was blank then no problem but it if needed to contain standard data then my method would be better.
Regards Darren
Thanks for your suggestions. I think it will help. I'm really new to PHP though so it's taking some time for me to get it.
I noticed your answer as to how to clear the text file for that other guy. Can you tell me how I can INSERT a text file somewhere in my html. I'm writing a school district site, I need a few people to be able to update stuff easily. For instance, a lunch lady opening a text file in note pad and typing in it what's for lunch that day, and the wbsite updating from that text file. I tried <INS CITE="filename"> </INS> in html, but it didnt work. Any ideas? I'm trying to avoid using ASP.