Create a Full Featured Registration and Login Module in CodeIgniter

Registration and Login is one of the primary module in any data management system. In this tutorial, we will explain how to create user Registration authentication and user Login system using the CodeIgniter with activation process. Once active the user can login, a reset option is available to reset the password and etc. Also Using password_hash() and password_verify() algorithm.

Features of Registration and Login Module

  • Registration form
  • Login form
  • Forgot password
  • Logout feature
  • password_hash() algorithm
  • password_verify() algorithm
  • Change Password feature
  • Email authentication for registration process
  • Using SMTP (Simple Mail Transfer Protocol)
  • Forms validations on login and registration panel
  • On success the module redirects to the user profile page
Step 1: Create Database
For this tutorial, you need a MySQL database with the following table:
Step 2: Configure Database access
Update the file application/config/database.php in your CodeIgniter installation with your database info:
Step 3: Update routes file
Add code the file application/config/routes.php in your CodeIgniter installation with you controller’s name.
Step 4: Update autoload file
In the file application/config/autoload.php you can configure the default libraries you want to load in all your controllers. For our case, we’ll load the database and session libraries, since we want to handle user sessions, and also the URL helper for internal link generation.
Step 5: Create Model
Create a model file named Auth_model.php inside “application/models” folder.
Step 6: Create controllers
Create a controllers file named Auth.php inside “application/controllers” folder.
Step 7: Create mailing class with SMTP (Simple Mail Transfer Protocol) functionality
Create a model file named "Mail.php" inside “application/models” folder.
Step 8: Create views for registration
Create a views file named register.php inside “application/views/auth” folder.
Step 9: Create views for login
Create a views file named login.php inside “application/views/auth” folder.
Step 10: Create views for Forgot Password
Create a views file named forgotpwd.php inside “application/views/auth” folder.
Step 11: Create views for profile page
Create a views file named index.php inside “application/views/auth” folder.
Step 12: Create views for edit profile page
Create a views file named edit.php inside “application/views/auth” folder.
Step 13: Create views for change password page
Create a views file named changepwd.php inside “application/views/auth” folder.