This is a simple PHP authentication system using PDO and MySQL.
It includes user registration, login, role-based redirection, and a basic dashboard for admin users.
- index.php – Home page, displays welcome message
- login.php – Login form page
- register.php – Registration form page
- dashboard.php – Admin dashboard page
includes/
- db.php – Database connection using PDO
- auth.php – Session and role-based access control
- process_login.php – Handles login form submission
- process_register.php – Handles registration form submission
assets/css/
- style.css – Styling for login, register, index, and dashboard pages
database/
- php-auth-system.sql – SQL file to create
users
table
- User registration with name, email, password, and role (
user
oradmin
) - Secure password hashing using
password_hash()
- Role-based redirection:
admin
→ dashboard.phpuser
→ index.php
- Session management to protect pages
- Simple and clean responsive UI using CSS
- Database schema included for easy setup
- Clone the repository:
git clone https://github.com/your-username/php-auth-system.git
-
Import the database:
- Open phpMyAdmin or MySQL client
- Import
database/php-auth-system.sql
-
Configure database connection in
includes/db.php
:
$localhost = "localhost";
$username = "root";
$password = "";
$dbname = "php-auth-system";
- Start your local server and open:
http://localhost/php-auth-system/index.php
- No external frameworks are used, only vanilla PHP, HTML, CSS, and MySQL.
- Passwords are securely hashed.