This is a simple and secure login system built using HTML, CSS, JavaScript, and PHP. It includes features such as password hashing, session-based authentication, and protection against SQL injection.
- User Registration: Users can sign up with a unique username and password.
- Secure Login: Passwords are hashed using
password_hash()before being stored in the database. - Session-Based Authentication: Uses PHP sessions to maintain user login status.
- SQL Injection Protection: Queries are executed using prepared statements.
- Secure Cookies: HTTP-only cookies are used for added security.
- Form Validation: JavaScript is used to ensure proper input validation before submission.
- Frontend: HTML, CSS, JavaScript
- Backend: PHP
- Database: MySQL (MariaDB with XAMPP)
Ensure you have the following installed:
- XAMPP (Apache, MySQL, PHP)
- A text editor (e.g., Sublime Text, VS Code)
- Open phpMyAdmin in your browser (
http://localhost/phpmyadmin). - Create a new database named ``.
- Run the following SQL script to create the
userstable:
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
user_name VARCHAR(50) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL
);- Insert a test user:
INSERT INTO users (user_name, password) VALUES ('testuser', '$2y$10$bOl0VoYdugylvPR3TDtgfOqvBIPXc9omGrN368Dn6FgldtDsBrB0i');(The password is pre-hashed for security.)
- Place the project files in
C:\xampp\htdocs\Login. - Start Apache and MySQL in XAMPP.
- Open
http://localhost/Login/index.htmlin your browser.
Login/
│── index.html # Login form
│── signup.php # User registration
│── login.php # Handles login logic
│── logout.php # Handles user logout
│── styles.css # Basic styling for the UI
│── README.md # Project documentation
- Implement a password reset feature.
- Add an admin panel to manage users.
- Improve UI with better styling and animations.
- Elly K
This project is open-source and free to use for learning purposes.
Note: If you encounter issues, ensure that your database is correctly set up and that XAMPP services are running.