简体   繁体   中英

COdeIgniter structure for login & registration

I am creating a login & registration system using CodeIgniter.

Currently I have a Model, View and Controller for login, with functions to validate, check username, etc and an registration model, view and controller, that does the registration.

I have chosen to separate the login and registration as a principle.

So right now i need to include functions to edit profile, and to check if logged in or not, and to check the user's role, and I would like to know how can i best do this, i have planned creating a user model and controller(no view), the main user controller would have the methods call to model's, but however the methods(updateprofile,islogin,etc) would be in different models, for example in the login model.

So is this design good/bad? How can it be done better. I would appreciate your suggestion's.

I really find no problem with your application structure. Its how you write your code and how will it easily be to update it in the future. For managing your models try using an ORM. PHPActiveRecord is a good start. With this, you no longer be creating alot of individual functions for your database transactions. Reference

You can create a User_Model and expand it as needed. You can see this CI auth lib for example as how build login & registration structure in CodeIgniter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM