tags:

views:

27

answers:

2

Hi everyone,

I have a file called config.php with contents that looks like this:

$setting_1 = "value1";
$setting_2 = "value2";
$setting_3 = "value3";
$setting_4 = "value4";

How can I use a form to edit/save these values from a webpage? Any help would be appreciated.

A: 

Make 4 input text boxes and save them into the settings array?

Google of "php form" and get many examples

edelwater
A: 

To read the values, you simply include the file (as you would when using the configuration). Then you can simply output the current configuration at the appropriate location in the form to make it appear as the default (or current) value.

When you save it, you pass the values just as you would with a normal html form, and - after validation of the values - simply construct a new string that is in the exact format as the config file.

Then you open the file for writing and replace the contents by the new values.

poke