I got this page, where I got some textfiles which contain some settings. I want my users to be able to change these textfiles.
Like having something similar to an iframe, where the user can see the content of the textfile in the middle of my page, and a save button below after they have edited it. Is this possible with PHP? Thanks!
OF course it's possible, there are some things to consider:
1. The files need to be writeable by the webserver (user nobody/httpd/apache) if the server doesn't allow suexec.
2. You'll load the file in a "textarea" not a "multi line text field" as dbgohan said.
3. Once it's edited the best way to avoid overwriting/locking would be to erase the entire file and write it again.
you'll use the following PHP functions:
fopen() to open the file
fread() to read the contents of the file
fputs() to write the user's input back into the file
fclose() to close an open file pointer
You can even get fancy and add some functions like converting special characters to avoid sql injection problems or parsing specific strings (like vBulletin and other forum scripts do to allow "customized code" - vbcode in vBulletin).