Page 1 of 1

Edit a file by submitting a form

Posted: Sat Apr 19, 2008 8:50 pm
by DJMiles
Well, I'm somewhat of a n00b with php, so go a little easy on me, please? :)

What I wanted to do, was create a form where a user would enter in information. And when the user clicks a submit button, it would insert the information that the user gave into another file. An example: the file that has the info written to would be a SQL connection file, with the form input being the info to connect to the database.

I know the file being written to has to be chmoded 777, but besides that, what code would I use?

Re: Edit a file by submitting a form

Posted: Sat Apr 19, 2008 9:37 pm
by flying_circus
I'm not exactly sure what you're trying to accomplish, but read the fopen() manual on php.net. Using fopen, fwrite, and fclose, you can open, edit, and close a file.

Re: Edit a file by submitting a form

Posted: Sat Apr 19, 2008 9:55 pm
by DJMiles
That's pretty much what I was looking for. Thanks a lot. :D

Re: Edit a file by submitting a form

Posted: Sun Apr 20, 2008 4:09 am
by markusn00b
You should really consider using a database!