Jump to content


editing config.php with form fields?


7 replies to this topic

#1 Hertick

    Young Padawan

  • Members
  • Pip
  • 4 posts

Posted 13 November 2007 - 04:28 PM

Hello everyone,

I'm just wondering.. i have made a config.php file for my website to work off and im just wondering how i could make a settings page, where it displays form fields from my config file with the path to it already typed in. Like you get on a CMS where you can edit the form fields on the settings page to direct it to certain paths and other fields like database host, name, username etc.. Just wondering how to create something like this so when you save it on the site it will automaticly update the config.php

If someone could possibly put me in the right direction of creating this or could help me i would be more than thankful.

Thanks, Neil :P

#2 Skylar.Bowen

    Young Padawan

  • Members
  • Pip
  • 4 posts
  • Gender:Male
  • Location:Omaha, NE USA

Posted 13 November 2007 - 05:16 PM

Try this

http://php.about.com/od/advancedphp/ss/file_write_php.htm

and

http://www.w3schools.com/php/php_file.asp

They both show examples on how to open a file and edit the info inside of it. If you need more help just let me know and I will further explain.

#3 Hertick

    Young Padawan

  • Members
  • Pip
  • 4 posts

Posted 13 November 2007 - 05:33 PM

View PostSkylar.Bowen, on Nov 13 2007, 05:16 PM, said:

Try this

http://php.about.com/od/advancedphp/ss/file_write_php.htm

and

http://www.w3schools.com/php/php_file.asp

They both show examples on how to open a file and edit the info inside of it. If you need more help just let me know and I will further explain.

Hello,

thanks for advise.. i don't know if this is what i am looking for.. I don't think i really made it clear on what time im "thing" i'm wanting. (one way to put it) lol :doh:

What i basicly mean is that say i uploaded a CMS and all CMS usely have a settings page where you can update your database details or site paths.. That's what im trying to make. Something what can allow my users to change there settings from form fields on a page instead of editing a file.

So basicly you can change the database name for example on the settings page and click save and it will automaticly reupload it to configure the new setting to the file.

Thanks, neil (thanks for quick responce) :P

#4 Skylar.Bowen

    Young Padawan

  • Members
  • Pip
  • 4 posts
  • Gender:Male
  • Location:Omaha, NE USA

Posted 13 November 2007 - 11:24 PM

So you want to use a form for people to edit a file? Or pull info from a database

#5 Hertick

    Young Padawan

  • Members
  • Pip
  • 4 posts

Posted 14 November 2007 - 01:11 PM

Basicly to edit information from the config.php using a form. So you can edit your database name, username and password. etc...

#6 nitr0x

    Young Padawan

  • Members
  • Pip
  • 201 posts

Posted 14 November 2007 - 04:00 PM

I don't know how it actually works, but I can explain it again for others.

Imagine you've downloaded some kind of CMS and you've installed it... you made a new table in your database and want to change the settings of the CMS so that it uses this newly created database, you go into the admin panel and it has a form field, and 4 fields...

mysql host, name, user and pass.

You can change one or more of these and save it, then it configures it in the config.php file.

Hope anyone else understands it now.

#7 Hertick

    Young Padawan

  • Members
  • Pip
  • 4 posts

Posted 14 November 2007 - 05:25 PM

Hello,

Thanks nitr0x for putting people in the right direction of what i mean. That's exactly what i want what you have just explained so thanks for for that :P yeah so that's what i basicly want help with doing is create a settings page like nitr0x has explained above.

#8 Skylar.Bowen

    Young Padawan

  • Members
  • Pip
  • 4 posts
  • Gender:Male
  • Location:Omaha, NE USA

Posted 14 November 2007 - 11:44 PM

well as i said in my first post you will pry want to use what i told you. You can oull varibles and post them into forms and you can make a update button and allow it to update that page. The fopen and fwrite will allow you to update config.php its not just for text files. Learn about forms and posting data and read what I gave you in the first two links.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users