I am relatively new to CodeIgniter and the MVC philosophy in general, so I'm trying to clarify this before making any bad habits.
I have an application that is registering. Users Currently, the stream is as follows:
- The user goes to "someebpage / register", which loads the controller's register function
- The controller checks whether the form is submitted - if it is not, show them the form, otherwise call the "register" function of the "users" model
- The user models the validation to ensure that the username is already completed. If so, it returns an error code (defined as a PHP constant) for this error.
- If the username has not yet been accepted, the model registers the user and returns TRUE.
- The controller collects what the model register function returns and displays an error page, success page, or database failure page based on the error code.
As you can see, I tried to move the logic as much as possible into the model. The only logic I couldn’t get around with was to validate the form, since it seems that CodeIgniter is forcing you to put it in the controller. (If no one knows how to do this)
Should I develop like this with CodeIgniter or with MVC in general?
Thanks in advance for your help.
source share