A complete user management system built with CodeIgniter 3 framework that includes authentication, authorization, and user administration features with DataTables integration.
- ✅ User registration and authentication system
- ✅ Role-based access control (Admin/User)
- ✅ Admin panel for user management
- ✅ DataTables with search, sort, and pagination
- ✅ Full CRUD operations for users
- ✅ Password security with BCRYPT hashing
- ✅ Client and server-side validation
- ✅ RTL support (Persian/Arabic interface ready)
- ✅ Responsive design with Bootstrap 5
- Installation
- Database Setup
- Configuration
- Usage
- Project Structure
- Security Features
- API Endpoints
- Contributing
- License
- PHP 5.6 or higher
- MySQL 5.7 or higher
- Web server (Apache/Nginx)
- Composer (optional for dependency management)
- Clone or download the repository to your web server directory
git clone https://github.com/your-username/ci3-user-management.git- Navigate to the project directory
cd ci3-user-management- Install dependencies (if using Composer)
composer installCREATE DATABASE task CHARACTER SET utf8 COLLATE utf8_general_ci;CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL UNIQUE,
`password` varchar(255) NOT NULL,
`role` enum('user','admin') DEFAULT 'user',
`created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;INSERT INTO users (name, email, password, role)
VALUES ('Admin User', 'admin@example.com', '$2y$10$...', 'admin');Note: Use BCRYPT to hash the password before inserting.
Edit application/config/database.php with your database credentials:
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'your_username',
'password' => 'your_password',
'database' => 'task',
'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
);Edit application/config/config.php to set your base URL:
$config['base_url'] = 'http://localhost/task/';- Open your browser and go to:
http://localhost/task - Use the default admin credentials to log in
- Access the user management panel under "Admin" section
/- Login page (default controller)/register- User registration/login- Login page/logout- Logout/profile- User profile/admin/users- User management panel
- View all users in a DataTable
- Add new users
- Edit existing users
- Delete users (with safety checks)
- Search and filter users
- Sort by different columns
task/
├── application/ # Main application directory
│ ├── config/ # Configuration files
│ │ ├── database.php # Database settings
│ │ ├── routes.php # URL routing
│ │ └── ... # Other config files
│ ├── controllers/ # Controller classes
│ │ ├── Auth.php # Authentication controller
│ │ └── admin/
│ │ └── Users.php # User management controller
│ ├── models/ # Model classes
│ │ └── User_model.php # User model
│ ├── libraries/ # Custom libraries
│ │ └── UserService.php # User service
│ ├── views/ # View templates
│ │ ├── admin/ # Admin panel views
│ │ ├── auth/ # Authentication views
│ │ └── templates/ # Shared templates
│ └── ...
├── assets/ # CSS, JS, images
├── system/ # CodeIgniter core
├── index.php # Main entry point
└── .htaccess # URL rewriting rules
- Secure password hashing with BCRYPT
- Session-based authentication
- Role-based access control
- Secure password verification
- Admin-only access to user management
- Prevention of self-deletion by admin
- AJAX request validation
- CSRF protection (if enabled)
- Server-side validation with Form Validation library
- Email uniqueness check
- Password strength validation
- XSS protection with input filtering
GET /admin/users/list- Retrieve users in JSON format for DataTables
POST /admin/users/create- Create new userPOST /admin/users/edit/{id}- Update user by IDGET /admin/users/edit/{id}- Get user data for editingPOST /admin/users/delete/{id}- Delete user by ID
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and development questions:
- CodeIgniter Forum: http://forum.codeigniter.com/
- GitHub Wiki: https://github.com/bcit-ci/CodeIgniter/wiki
- Slack: https://codeigniterchat.slack.com
Project Version: 1.0
Framework: CodeIgniter 3
Created: 2025