Originally posted by EricTRocks
I'm trying to create a news script and i am at the point where i need to edit the old news postings. Each posting is a seperate .txt file and they're all in a folder named files. I need to get each one listed in a form so i can edit the text. Any help?
Eric
Well, assuming you can recognise a posting from its file name, you can read the directory, and list the filenames found (sorted and filtered if necessary) as links that have the filename (suitably urlencoded()) in the querystring. The page the link goes to picks the filename out of the querystring, reads the file, displays it in a POST form inside a <textfield> so's you can edit it (there's also a submit button and a hidden field containing the filename).
Submit takes you to a confirmation page which redisplays the article, and provides two buttons (each in a separate form, for convenience); the "Back" button is in a GET form that has the filename as a hidden field, and goes to the editing page, the "Confirm" button is in a POST form that has both the filename and the text of the article in a hidden form. That one goes to whatever page it will be that writes the file back out.
If the filenames are too obscure, open each file, pull out sufficient text to make recognition possible, and display that on the listing page, instead of the filename. But still use the filename to identify it in the forms.
And consider using a database, instead.