Edit a file by submitting a form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
DJMiles
Forum Newbie
Posts: 5
Joined: Sat Apr 19, 2008 8:38 pm

Edit a file by submitting a form

Post 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?
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Edit a file by submitting a form

Post 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.
User avatar
DJMiles
Forum Newbie
Posts: 5
Joined: Sat Apr 19, 2008 8:38 pm

Re: Edit a file by submitting a form

Post by DJMiles »

That's pretty much what I was looking for. Thanks a lot. :D
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Edit a file by submitting a form

Post by markusn00b »

You should really consider using a database!
Post Reply