Welcome Guest, Not a member yet? Register   Sign In
Small project on MVC
#1

Hello, i've been recently using codeigniter, started with tutorials and examples, but i only found few examples for the "application" i need.
So i'm here now to ask you for help, if you could possibly explain to me how it should work.
I'm making an office application. The user need to login, and then he continue to the main page.
I've couldn't really understand how to manage this in MVC, ive already got this application in my own code (without frameworks), but i want to make it more efficient.
What models, controllers and views should i have to make an login page that will pass me data to the index (SESSION).
I don't ask you for a code, i'm just asking for a "chart" or something like that, that will help me understand the construction of this system.
Thank you!
Reply
#2

If you really want to learn the mechanics of an authentication system (how to login/logout), then you ought to look at some of the existing authentication libraries or packages that exist for CodeIgniter. I created Community Auth, but there are a few others.

In general you will have a user submit a form with their email and password. If there is a match in the database for the user, the password is compared to the one used in the form submission. If the password matches you set a session indicating that the user is logged in, and check for it on subsequent page loads. In reality this is a way over-simplified description of how authentication is handled.
Reply
#3

I know how the authentication is handled, like i've said before, i already wrote the application all by myself without frameworks, now i want to pass it to codeigniter, what i couldnt understand is how to pass all this to MVC, now i've got login.php with the form, and it passes data to functions.php where all the authentication is handled. But in codeigniter i got the controller that take the data from the view (that contains a from), and check it thought the model?
so basically i need an login_view->login_controller->login_model? and if true so pass to "home" with the specific data (session).
I just really cant understand the MVC mechanism.
Reply
#4

(This post was last modified: 06-07-2016, 02:18 AM by behrooz1x.)

(06-07-2016, 12:40 AM)PlorntXhizors Wrote: I know how the authentication is handled, like i've said before, i already wrote the application all by myself without frameworks, now i want to pass it to codeigniter, what i couldnt understand is how to pass all this to MVC, now i've got login.php with the form, and it passes data to functions.php where all the authentication is handled. But in codeigniter i got the controller that take the data from the view (that contains a from), and check it thought the model?
so basically i need an login_view->login_controller->login_model? and if true so pass to "home" with the specific data (session).
I just really cant understand the MVC mechanism.

I have done one project with your description. So if you want to bring your project to CI, you need to cut your script to some files(mainly 3 parts):
1- Part of your code that connects to database such as CRUD and other SQLs code, you must create a model class and create method for that  to handle  this section(this calls Model(M) of MVC pattern).
2- Parts of HTML that are commons to viewers and need some small different changes of HTML, for this you create a view in views folder for that (View(V) of MVC) .
3- Last part, some codes that extract different changes of HTML(for your view), use the Model class, handle cookies, sessions, and other brain part of your code , you create a Controller Class in controllers folder(Controller(C ) of MVC).

This system has many benefit for you, for medium or large site.

Good luck
RankUP
Reply




Theme © iAndrew 2016 - Forum software by © MyBB