A foundational script for any web application that requires user accounts. This Simple & Secure PHP Login System provides all the essential components for user registration, login, and session management, built with modern security practices in mind.

The code is clearly written and well-commented, making it an excellent starting point for beginners to learn about user authentication or for developers who need a quick and reliable login system to integrate into a new project.

Features:

  • User Registration: A clean form for new users to sign up.
  • User Login & Logout: Secure login and logout functionality.
  • Secure Password Hashing: Uses PHP's modern password_hash() and password_verify() functions to protect user passwords.
  • Session Management: Keeps users logged in as they navigate between pages.
  • Protected Page Example: Includes a sample "dashboard" page that is only accessible to logged-in users.
  • Easy to Integrate: Built with a simple structure that is easy to understand and expand upon.

How to Set Up:

  1. Create the Database Table: Import the database.sql file into your MySQL database to create the required users table.
  2. Configure Database Connection: Open the config.php file and enter your database host, name, username, and password.
  3. Upload Files: Upload all the script files to a folder on your server and navigate to it in your browser.

To protect another page, simply add the PHP code snippet from the top of dashboard.php to the top of your other pages.