This is a simple yet secure login and registration system built using PHP, CSS, and Bootstrap. The system allows users to register with a name, email, and password, log in with their credentials, access a user-specific page, and log out. It includes security features like password hashing, CSRF protection, and session management, with a responsive design powered by Bootstrap 5 and custom CSS. The system uses a MySQL database to store user data.



- User registration with email and password.
- Secure login with session-based authentication.
- User-specific page with welcome message and logout option.
- Password hashing with
password_hash()
and verification withpassword_verify()
. - CSRF protection to prevent cross-site request forgery.
- Responsive design with Bootstrap and custom CSS.
- Session management for user tracking and logout functionality.
- XAMPP or WAMP: Install XAMPP (https://www.apachefriends.org/) or WAMP (https://www.wampserver.com/) to set up a local server with Apache, MySQL, and PHP.
- A web browser to access the application.
- Basic knowledge of PHP, MySQL, and web development.
- Download and install XAMPP or WAMP on your computer to create a local server environment.
- Start the Apache and MySQL services after installation.
- Open phpMyAdmin by visiting
http://localhost/phpmyadmin
in your browser. - Create a new database named
login_db
. - Create a table named
users
with the following schema:Column Type Attributes Default Extra id
INT Primary Key None AUTO_INCREMENT name
VARCHAR(50) Not Null None email
VARCHAR(100) Not Null None password
VARCHAR(255) Not Null None user_type
VARCHAR(50) Not Null 'user' - Ensure the
email
column length is sufficient to avoid truncation of email addresses.
- Place the project files in the
htdocs
folder (XAMPP) orwww
folder (WAMP). - Edit
connection.php
with your MySQL credentials:<?php $host = 'localhost'; $user = 'your_username'; // e.g., 'root' $pass = 'your_password'; // e.g., '' for default XAMPP/WAMP $db = 'login_db'; $conn = new mysqli($host, $user, $pass, $db); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } ?>