PHP User Login and Management Codeigniter – HMVC
$14.00
37 sales
LIVE PREVIEWCodeigniter User Login and Management Review
As a developer, I’m always on the lookout for reliable and efficient solutions to streamline my projects. Recently, I came across the Codeigniter User Login and Management system, and I’m excited to share my review with you.
Overview
The Codeigniter User Login and Management system is a PHP + MySQLi powered script built under the CodeIgniter framework (version 3.x). It allows the registration and management of users with an admin panel, providing secure login, registration, user management, email templates, roles and permission, email verification, and invite users via email.
Features
The system boasts an impressive list of features, including:
- Built with CodeIgniter 3.x
- HMVC architecture
- User registration
- User login
- Login with email
- Password reset
- Avatar and logo upload
- E-Mail verification for new users
- Manage users
- Invite new users for registration
- Restrict public user registration
- Manage user types
- Manage permissions
- Assign permission to user type
- Built using AdminLTE
- Bootstrap responsive theme
- Email templates for forgot password and invite users
- SMTP email setting
- Site logo, title, and favicon change settings
Ease of Use
The system is designed to be easy to use, even for those without extensive PHP experience. The HMVC architecture makes it easy to navigate and customize the system. The admin panel is well-organized, allowing you to manage users, roles, and permissions with ease.
Customization
The system is highly customizable, with a "Do It Yourself" (DIY) tool that allows you to add new CRUDs, modify field names, and customize the system to your needs.
Demo and Credentials
The demo link is available, and the credentials are:
- UserName: admin
- Password: 123456
Score
I give the Codeigniter User Login and Management system a score of 0 out of 10. The system is well-designed, easy to use, and highly customizable. The HMVC architecture makes it easy to navigate, and the admin panel is well-organized. The system is also highly secure, with features like email verification and SMTP email setting.
Conclusion
Overall, the Codeigniter User Login and Management system is an excellent solution for any project that requires user registration and management. With its ease of use, high customizability, and robust features, it’s a must-have for any developer.
User Reviews
Be the first to review “PHP User Login and Management Codeigniter – HMVC” Cancel reply
Introduction
Welcome to the tutorial on using the PHP User Login and Management Codeigniter - HMVC. In this tutorial, we will be going over the process of setting up and using a user login and management system using Codeigniter, a popular PHP framework. This system will allow users to register, log in, and manage their accounts.
The system will include the following features:
- User registration
- User login
- User account management (edit profile, change password)
- User authentication (to ensure only logged in users can access certain pages)
By the end of this tutorial, you will have a fully functional user login and management system using Codeigniter - HMVC.
Prerequisites
Before we begin, make sure you have the following:
- Codeigniter - HMVC installed on your server
- A text editor or IDE (Integrated Development Environment) such as Sublime Text, Atom, or Visual Studio Code
- Basic knowledge of PHP and HTML
Step 1: Setting up the Database
The first step is to set up the database for our user login and management system. Create a new database and add the following tables:
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL,
`password` varchar(255) NOT NULL,
`created_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `user_sessions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`session_id` varchar(255) NOT NULL,
`created_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Step 2: Creating the Controller
Create a new controller called "Auth" in the "controllers" folder. In this controller, we will define the methods for user registration, login, and account management.
Auth.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Auth extends MX_Controller {
public function __construct() {
parent::__construct();
$this->load->library('session');
$this->load->helper('form');
}
public function index() {
$this->load->view('login');
}
public function register() {
$this->load->view('register');
}
public function login() {
if ($this->input->post()) {
$username = $this->input->post('username');
$password = $this->input->post('password');
$user = $this->users_model->get_user_by_username($username);
if ($user && password_verify($password, $user->password)) {
$this->session->set_userdata('user_id', $user->id);
redirect('dashboard');
} else {
$this->session->set_flashdata('error', 'Invalid username or password');
redirect('auth');
}
}
$this->load->view('login');
}
public function logout() {
$this->session->unset_userdata('user_id');
redirect('auth');
}
public function dashboard() {
if ($this->session->has_userdata('user_id')) {
$this->load->view('dashboard');
} else {
redirect('auth');
}
}
public function profile() {
if ($this->session->has_userdata('user_id')) {
$user_id = $this->session->userdata('user_id');
$user = $this->users_model->get_user_by_id($user_id);
$this->load->view('profile', array('user' => $user));
} else {
redirect('auth');
}
}
public function edit_profile() {
if ($this->session->has_userdata('user_id')) {
$user_id = $this->session->userdata('user_id');
$user = $this->users_model->get_user_by_id($user_id);
if ($this->input->post()) {
$new_username = $this->input->post('username');
$new_email = $this->input->post('email');
$user->username = $new_username;
$user->email = $new_email;
$this->users_model->update_user($user);
$this->session->set_flashdata('success', 'Profile updated successfully');
redirect('auth/profile');
} else {
$this->load->view('edit_profile', array('user' => $user));
}
} else {
redirect('auth');
}
}
public function change_password() {
if ($this->session->has_userdata('user_id')) {
$user_id = $this->session->userdata('user_id');
$user = $this->users_model->get_user_by_id($user_id);
if ($this->input->post()) {
$old_password = $this->input->post('old_password');
$new_password = $this->input->post('new_password');
if (password_verify($old_password, $user->password)) {
$user->password = password_hash($new_password, PASSWORD_DEFAULT);
$this->users_model->update_user($user);
$this->session->set_flashdata('success', 'Password changed successfully');
redirect('auth/profile');
} else {
$this->session->set_flashdata('error', 'Invalid old password');
redirect('auth/profile');
}
} else {
$this->load->view('change_password', array('user' => $user));
}
} else {
redirect('auth');
}
}
}
Step 3: Creating the Models
Create a new model called "Users" in the "models" folder. In this model, we will define the methods for getting and updating user data.
Users.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Users extends MX_Model {
public function get_user_by_username($username) {
$this->db->where('username', $username);
$query = $this->db->get('users');
return $query->row();
}
public function get_user_by_id($user_id) {
$this->db->where('id', $user_id);
$query = $this->db->get('users');
return $query->row();
}
public function update_user($user) {
$this->db->update('users', $user);
}
}
Step 4: Creating the Views
Create the following views in the "views" folder:
- login.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
Login
* **register.php**
```php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Register</title>
</head>
<body>
<h1>Register</h1>
<?php echo form_open('auth/register');?>
<label for="username">Username:</label>
<input type="text" name="username"><br><br>
<label for="email">Email:</label>
<input type="email" name="email"><br><br>
<label for="password">Password:</label>
<input type="password" name="password"><br><br>
<input type="submit" value="Register">
</form>
</body>
</html>
- profile.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
Profile
Username: username?>
Email: email?>
<a href="">Edit Profile <a href="">Change Password
* **edit_profile.php**
```php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Edit Profile</title>
</head>
<body>
<h1>Edit Profile</h1>
<?php echo form_open('auth/edit_profile');?>
<label for="username">Username:</label>
<input type="text" name="username" value="<?php echo $user->username?>"><br><br>
<label for="email">Email:</label>
<input type="email" name="email" value="<?php echo $user->email?>"><br><br>
<input type="submit" value="Update Profile">
</form>
</body>
</html>
- change_password.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
Change Password
**Step 5: Creating the Routes**
Create a new file called "routes.php" in the "routes" folder. In this file, we will define the routes for our application.
**routes.php**
```php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$route['default_controller'] = 'auth';
$route['auth'] = 'auth/index';
$route['register'] = 'auth/register';
$route['login'] = 'auth/login';
$route['dashboard'] = 'auth/dashboard';
$route['profile'] = 'auth/profile';
$route['edit_profile'] = 'auth/edit_profile';
$route['change_password'] = 'auth/change_password';
Conclusion
That's it! You now have a fully functional user login and management system using Codeigniter - HMVC. You can use this system to register, log in, and manage your accounts.
Remember to always validate and sanitize user input to prevent SQL injection and other security vulnerabilities.
Here is an example of a complete settings configuration for PHP User Login and Management Codeigniter - HMVC:
Database Settings
$db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => 'root', 'password' => '', 'database' => 'ci_hmvc', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, 'db_debug' => (ENVIRONMENT!== 'production'), 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE, 'failover' => array(), 'save_queries' => TRUE );
Authentication Settings
$config['auth'] = array( 'username_field' => 'username', 'password_field' => 'password', 'identity' => 'username', 'hash' => 'md5', 'min_password_length' => 8, 'email_activation' => FALSE, 'remember_me' => array( 'cookie_name' => 'ci_hmvc_remember_me', 'cookie_expiration' => 86400 // 1 day ) );
User Settings
$config['user'] = array( 'table_name' => 'users', 'primary_key' => 'id', 'username_field' => 'username', 'email_field' => 'email', 'password_field' => 'password', 'activation_field' => 'activated', 'activation_key_field' => 'activation_key', 'reset_password_field' => 'reset_password_key' );
Role Settings
$config['role'] = array( 'table_name' => 'roles', 'primary_key' => 'id', 'name_field' => 'name', 'description_field' => 'description' );
Permission Settings
$config['permission'] = array( 'table_name' => 'permissions', 'primary_key' => 'id', 'role_id_field' => 'role_id', 'permission_field' => 'permission' );
Login Settings
$config['login'] = array( 'login_url' => 'login', 'logout_url' => 'logout', 'login_redirect' => 'dashboard', 'logout_redirect' => 'login' );
Remember Me Settings
$config['remember_me'] = array( 'cookie_name' => 'ci_hmvc_remember_me', 'cookie_expiration' => 86400 // 1 day );
Forgot Password Settings
$config['forgot_password'] = array( 'email_template' => 'forgot_password_email', 'reset_password_url' => 'reset_password' );
Reset Password Settings
$config['reset_password'] = array( 'reset_password_url' => 'reset_password', 'reset_password_redirect' => 'login' );
Here are the features of the PHP User Login and Management Codeigniter - HMVC:
- Built with CodeIgniter 3.x: The system is built using CodeIgniter version 3.x.
- HMVC architecture: The system uses HMVC (Hierarchical Model-View-Controller) architecture.
- User registration: Users can register with the system.
- User Login: Users can log in to the system.
- Login with email: Users can log in using their email address.
- Password reset: Users can reset their passwords.
- Avatar and logo upload: Users can upload their avatars and logos.
- E-Mail verification for new users: New users must verify their email addresses before they can log in.
- Manage Users: Admins can manage user accounts.
- Invite new user for registration: Admins can invite new users to register with the system.
- Restrict Public User Registration: Public user registration can be restricted.
- Manage User Types: Admins can manage user types.
- Manage permissions: Admins can manage permissions.
- Assign permission to User Type: Admins can assign permissions to user types.
- Built using AdminLTE: The system is built using AdminLTE.
- Bootstrap Responsive Theme: The system uses a responsive theme built with Bootstrap.
- Email Templates for Forgot Password & Invite users: Email templates are provided for forgot password and invite users.
- SMTP Email Setting: SMTP email settings are supported.
- Site Logo & Title & Favicon Change settings: Site logo, title, and favicon can be changed.
Note that each feature is listed on a separate line.
Related Products
$14.00
There are no reviews yet.