Re: Re: Forms
| From: | C.R. | Date: | Thu, 08 May 2003 13:02:34 +0000 |
| Subject: | Re: Re: Forms | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146664@lists.php.net to get a copy of this message | ||
> How are you doing validation? With PHP or Javascript?
PHP
> There's nothing wrong with your method, but it's harder to maintain as a
> change in one area must be supported with a change in another.
As does your method - the difference being that my method requires 2 changes
and yours requires 3, which makes mine easier to maintain and update, and is
why I wrote it this way.
> For instance, if you add a field to your form, you must now add it to your
> database or you must strip out the value before you "create" your SQL. So
> your presentation affects your logic, instead of the two being separate.
Since the whole purpose of the form is to gather data to input into a
database, my method is much easier to maintain. I just add the field to the
form and add the field to the database. I never have to touch the query as
it will automatically pick up the new form input. There will never be a
field in this form that isn't entered into the database.
> If you explicity wrote out your query, then changes in your form or
> presentation wouldn't affect the PHP code with your query.
This method adds one more step. Now I have to write out a seperate query for
the newly added form input, making my method more efficient to maintain.
Which is what I am talking about when I say efficiency.
> Either way, as long as your validating everything prior to this on the
> server side, use whatever method you want.
>
> I always place all of my validated variables into another array. You could
> then use your method on this new array. The reason I do this is so that I
> only use validated variables in queries, output, and links later in the
> code. I don't use the $_GET, $_POST variables directly as they may be
> tainted.
> ---John Holmes...
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>