5
The MVC standard has three layers
- View: Your views are the forms of data presentation to the user. In short it would be an html, flash, air, or whatever type of interface you will adopt. In the view should have no business rule, except simple command blocks like a
for
orforeach
to present a list of records. - Controller: The controller will handle communication between the view and the model. Here you will process data received from the request, send to model methods, and pass and present the proper view. Here you can also have watering like email sending, permission validation, etc.
- Model: The model should get all its business rule related to the database. Whatever the query or manipulation of data should stay inside.
To be more specific with your question, the form would be in the view, the controller will receive the data, and record sessions and cookies, and to query the data in the database you will use your models.
Tips
There are some layers that can be added that increase the possibility of reusing code as a layer called service, which would be a layer where there would be rules unrelated to the data, but of great importance.
In the service layer could contain a class called Autenticação
for example with methods that can verify if a user is logged in, because it uses the session or cookie and not the database, or even for the registration of users who in addition to registering in the database using the model, must send a confirmation email.
Using a service layer enables multiple rules to be reused across all controllers.
You can find more information about the MVC right here on Stack Overflow as well as, tips to create secure authentication systems.
Are you using some framework or are doing it from scratch?
– Erlon Charles
I’m doing it by hand,.
– Thiago
Then you are the one who should define the rules of your system, it can be in both controller and model, it depends only on which paradigm you intend to use
– Erlon Charles