18 September 2017

Create a User Registration and Login System in PHP and MySQLi



Today i will share Simple User Registration & Login Script in PHP and MySQLi, i will explain the basic functionality of registration and access secured area. In this tutorial user can register, login to member secured area and logout.

Steps to Create Simple User Registration & Login Script in PHP and MySQLi

  1. Create a Database
  2. Create a Database Table with Following Five Fields:
    id, username, email, password, trn_date
  3. Create a Registration Form
  4. Create a Login Form
  5. Connect to the Database by using PHP
  6. Authenticate Logged in User
  7. Create Index Page
  8. Create Dashboard Page
  9. Create a Log Out
  10. Create a CSS File

1. Create a Database

To create a database, login to phpmyadmin and click on database tab, enter your database name and click on create database button or simply execute the below query. In my case i created database with the name register.

2. Creating a Database Table

To create table, execute the below query in SQL.

3. Creating a Registration Form

Simple create a page with name registration.php and paste the following code in it.

registration-php

4. Creating a Login Form

Create a page with name login.php and paste the following code in it.

login-php

5. Connect to the Database

Create a page with name db.php and paste the below code in it.

6. Authenticate Logged in User

Create a page with name auth.php and paste the below code in it.

7. Creating Index Page

Create a page with name index.php and paste the below code in it.

secured-area

8. Creating Dashboard Page

Create a page with name dashboard.php and paste the below code in it.

dashboard

9. Creating a Log Out

Create a page with name logout.php and paste the following code in it.

10. Creating a CSS File

Create a page with name style.css and paste the below code in it.
Note: In this tutorial CSS file is placed in css/style.css folder. So make sure that you also placed CSS file in the same css folder.

If you found this tutorial helpful so share it with your friends, developer groups and leave your comment.

Start typing and press Enter to search