A robust, object-oriented PHP authentication system featuring user registration, login, and session management. Recently modernized with a sleek UI and improved security practices.
- Object-Oriented Design: Built using PHP classes for modularity and maintainability.
- Secure Authentication:
- User Registration and Login.
- Session Management.
- Password Hashing (MD5 - Note: Consider upgrading to
password_hashfor production).
- Modern UI:
- Bootstrap 5: Utilizes the latest Bootstrap 5 via CDN for responsive design.
- Custom Typography: Uses 'Plus Jakarta Sans' for a modern, clean look.
- Enhanced UX: Floating labels, card-based layouts, and smooth transitions.
- Client-Side Validation:
- Real-time form validation using vanilla JavaScript.
- User-friendly error messages (no annoying alerts).
- Email format and password strength checks.
- PHP 8.0 or higher.
- MySQL Database.
- Web Server (Apache/Nginx) or PHP built-in server.
-
Clone the Repository
git clone <repository-url> cd oop-php-authentication-system
-
Database Setup
- Create a new MySQL database named
oop_log_mod. - Import the provided SQL file:
mysql -u root -p oop_log_mod < users.sql
- Create a new MySQL database named
-
Configuration
- Open
include/db_config.php. - Update the database credentials to match your environment.
- For MAMP Users:
define('DB_PASSWORD', 'root'); // Default MAMP password // ... $this->connection = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE, 8889, '/Applications/MAMP/tmp/mysql/mysql.sock');
- Open
-
Run the Application
- Using PHP Built-in Server:
Access at:
php -S localhost:8000
http://localhost:8888/login.php - Using MAMP/XAMPP:
Place the folder in
htdocsand access via your local server URL (e.g.,http://localhost:8888/oop-php-authentication-system/login.php).
- Using PHP Built-in Server:
assets/: CSS and JavaScript files.css/style.css: Custom styles and overrides.js/script.js: Form validation logic.
include/: PHP classes and partials.class.user.php: Core user logic.db_config.php: Database connection settings.header.php&footer.php: Shared layout files.
login.php: User login page.registration.php: User registration page.home.php: Protected dashboard page.
Original tutorial by Adnan for W3Programmers. Refactored and modernized by Adnan.