You are here: Re: [PHP] Form handling « PHP « IT news, forums, messages
Re: [PHP] Form handling

Posted by Dan on 05/14/05 01:25

Jason Barnett wrote:
> Dan wrote:
>
>> Richard Lynch wrote:
>
> ...
>
>>> The "value added" of the central switch seems dubious to me.
>>>
>>> Just my opinion.
>>>
>>
>> Richard -
>>
>> I want your opinion, which is why I'm taking a stab at the list ;)
>>
>> What other methods would be good to use? Using a giant if statement?
>>
>> Thanks
>> -dant
>
>
> Nononono.... a giant "if" statement is still a case of you trying to
> control all form processing in one centralized location. I won't
> venture a guess as to why Richard doesn't approve of the centralized
> approach, but rather just pointing out that if() is logically similar to
> switch().
>
> Now going back to your original question... one easy to predict problem
> is that you've forgotten to handle form submission errors. I mean
> surely you will want to validate the incoming data and do something
> sensible if the data doesn't match some regular expression(s). If
> you're really trying to go for a centralized approach then I'd say this
> validation should be handled through this main script.
>
> A simple alternative? Each form has its "target" attribute set to
> itself. You start out with invalid data. Then when the form POSTs to
> itself you can validate the incoming data within the same script where
> the form elements are located. This approach puts all of the business
> logic for one page *inside the one page*. It makes debugging a lot
> simpler because, well, if you have a problem with page1.php then you
> know it lies somewhere in the script page1.php instead of any of the
> following:
>
> - page1.php
> - controller.php
> - index.php
> - page2.php
> - etc.
>
> One of the easiest ways to reduce maintenance is to make it easy to find
> your bugs. I'm not being condescending to you, because we all have
> bugs. But it sure is easier to fix them when you can find them. :)
>


Jason -

Very valueable input, I appreciate that.

I did not forget about error checking. Error checking (or currently
lack thereof) is the reason why I sent a message to this list.

However, since I'm anal, I want the entire page to be named index.php,
which is why I am stuck on the idea of making each page's "target" set
to index.php WITH $_SESSION['step'] being set to 1, 2, 3, whichever is
the next step in the process. If this is bad, what are my alternatives now?

Thanks!
-dant

 

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

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