| 
 Posted by Phil Latio on 06/22/07 05:17 
I am designing a relatively simple CMS with the usual Item, Category and  
User scenario. My question here relates to how I implement the User  
registration on this application. Currently I have the following: 
 
register.php 
classes/class.Form.php 
classes/class.Validation.php 
classes/class.User.php 
classes/class.MySQL.php 
templates/register.tpl.php 
 
The thing that is really bugging me is how I perform the validation on what  
is entered on the register.php page? 
 
My first version (which I actually coded) simply created a new instance of  
the Validation class on the register.php page then performed numerous if  
statements with an error increment counter and if that returns zero (once  
all the tests are completed) then proceed else redisplay registration.php  
page. Works OK but looks terribly ugly and I am convinced there are far  
better approaches. 
 
My second idea is to use CRUD methods within the User class and have the  
User class call the validation directly. 
 
My third idea was to somehow apply the validation rules to the form objects.  
I have seen that some frameworks use this method but my problem is that I am  
really bad at understanding other people's code. 
 
I keep hearing the term "design patterns" and just wondering if reading a  
book or two on that subject might clear my head on how to progress forward.  
The problem is not that I cannot code this, it's the approach I should take  
and would value some opinions by the piers of the group. 
 
Cheers 
 
Phil
 
[Back to original message] 
 |