You are here: Re: Saving configuration options from POST data « PHP Programming Language « IT news, forums, messages
Re: Saving configuration options from POST data

Posted by Jerry Stuckle on 09/13/07 03:53

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.
> <input name="option_name" />
>
> 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_).
> <input name="u_option_name" />
>
> 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 <option>s which can be generated by other functions, e.g.
> category list).
>
> 4. Array (more code):
>
> $array = array(
> 'opt1' => (int) $_POST['u_option']
> );
>
> The main configuration page has above 30 options. However, the method
> with $o -> add(...) may be slower. What do you think about it? Which
> choice is the best or maybe you have other solutions?
>

Personally, I'd place it in a database. But then I like databases :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация