User Authentication System
A simple user authentication system with input validation and Email verification feature. Made with PHP and SQL. User authentication is a standard security mechanism, It allows identified users to access any digital application or website. It strictly prevents unidentified users from accessing web or mobile application
Features
Features include:
- Signin and Signup forms with Bootstrap 4
- MySQL database connection with PHP 7 project
- User data management in session
- PHP server-side validation
- Handling error messages
- Sending user verification email using SwiftMailer plugin
- Securing a password with the password hash mechanism
- Password verification
- URL redirection based on userβs logged-in state
- Display logged-in userβs data using PHP 7 session
- Logout and destroying the session
File structure
How project is been structured:
config/db.php
: Contains function for database connectioncontrollers/login.php
: Contains function for login authenticationcontrollers/register.php
: Contains function for Signup authenticationcontrollers/user_activation.php
: Contains function for user email authenticationcss/style.css
: Minimal stylecss/bootstrap.min.css
: Bootstrap library stylesjs/bootstrap.min.js
: Bootstrap JS libjs/jquery.min.js
: Jquery JS liblib
: Contains 3rd party librarydashboard.php
: Display user info after verificationdb.sql
: SQL commandindex.php
: Login form pagelogout.php
: User logout commandsignup.php
: Sign up form pageuser_verification.php
: Display user account was successfully verified.
3rd party library
SwiftMailer PHP library was used here in this project for user email verification after sign up.
Install the SwiftMailer php plugin to send the verification mail to the user, i used the following composer command to install the SwiftMailer library. Make sure you have composer installed on your development machine.
composer require "swiftmailer/swiftmailer:^6.0"
Bash
You need to import the SwiftMailer library and add the SwiftMailer script also define the email template that will be sent to the user.
Or alternatively, I have zipped up the SwiftMailer library. Check the lib
folder and extract the lib.zip
file.
installation
Make sure you're running a local server on your computer system. Use XAMP or WAMP.
- Clone the repo
- Unzip inside the htdocs or www directory
- Create a database and name it
userauth
or you can decide to edit theconfig/db.php
file to specify your database information. - import the db.sql file in the database
- Run the project. I use
localhost:8080/php-user-authentication
You can modify this project to your need since it is open source.
Star π if you love this project and follow. π