We can do it in different ways. Configuration data are sent by POST.
Some of them should be parsed before saving to file.
Perhaps, I will use var_export(). However, how to do it best?
1. Without a class / function.
Fields names have no prefix and are equal to $cfg array's indexes.
In every file of options form (e.g. main options, content options, e-
mail...) you insert:
if(file_put_contents('cfg/file_name.php', var_export($_POST,1), 2))
{
...
}
If you must parse some data:
$_POST['data'] = Clean($_POST['data']);
2. With a class / function.
Fields names may contain prefix (e.g. u_).
$o = new Config(...);
$o -> add('option_name', 'int', 50);
No, it isn't good example. You can have textarea fields (even with
editor), text, radio (more choices for 1 option), checkbox, select
(with
Re: Saving configuration options from POST data
am 13.09.2007 05:53:34 von Jerry Stuckle
WebCM wrote:
> We can do it in different ways. Configuration data are sent by POST.
> Some of them should be parsed before saving to file.
>
> Perhaps, I will use var_export(). However, how to do it best?
>
> 1. Without a class / function.
> Fields names have no prefix and are equal to $cfg array's indexes.
>
>
> In every file of options form (e.g. main options, content options, e-
> mail...) you insert:
> if(file_put_contents('cfg/file_name.php', var_export($_POST,1), 2))
> {
> ...
> }
>
> If you must parse some data:
> $_POST['data'] = Clean($_POST['data']);
>
> 2. With a class / function.
> Fields names may contain prefix (e.g. u_).
>
>
> Saving data:
> $o = new Config(...);
> $o -> add('option_name', 'int');
> $o -> add('option_name');
> $o -> save('file_name'); //or: $o = null;
>
> 3. Method 2 with dynamic options forms:
>
> $o = new Config(...);
> $o -> add('option_name', 'int', 50);
>
> No, it isn't good example. You can have textarea fields (even with
> editor), text, radio (more choices for 1 option), checkbox, select
> (with