This project demonstrates a real life login and registration page complete with database integration, password hashing, unique username & email enforcement and efficient error handling.
Before getting started, be sure to:
- Install XAMMP to run MySQL and Apache.
- Create the database with
CREATE DATABASE userdb;This project uses the name userdb but you can use whatever name you like. Note that you will need to modify the code to suit your db naming conventions so for simplicity sake, use the userdb naming convention
3. Create the table and insert the columns
CREATE TABLE accounts (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) UNIQUE,
email VARCHAR(255) UNIQUE,
password_hash VARCHAR(255)
);- Ensure a proper connection configuration: typically these projects use something like this
$host = "localhost";
$dbname = "dbname";
$username = "root";
$password = "";Suggested to follow this convention but your use case may differ. Adjust accordingly if needed.
- Clone the repository.
- Configure the database connection in PHP files if needed.
- Follow the setup instructions to create the database and tables.
- Run the project using XAMPP.
On the first visit, the user will be presented with the landing page prompting either a login or register response.


For successful registration, a few conditions will need to be met:
- All fields must be filled out
- Username & email must be unique: no duplicates
- Password must contain at least 1 character, 1 letter and be at least 8 characters long
- Passwords must match
Missing any one of these conditions will results in some of the following errors

Once you've met the required criteria, your account will be created and you will be prompted to log in

For a successful login, you only need to enter valid credentials. Attempting to enter an invalid username or password combination will results in an error

Once logged in, you will see a running table of current active users within the database. Displayed in this table is a list of UserID, Username and Email associated with current active users. Click logout to terminate the session and go back to the landing page

Note: when attempting to visit index.php outside of a valid session, user will be automatically redirected to the landing page to prevent unauthorized access.
This project is licensed under the MIT License. See the MIT License for details.

