How to create a Registration and Login System with PHP and MySQL. Here is the step by step easy solution to build a registration and login form in php and mysql. Now a days almost every online website supports Registration and login functionality. So, it is required to add a login system in latest web applications.
In this Example, i walk through the complete process of creating a user registration system. Here Users can create an account by providing profile membername, password, Birthdate, email. And then the account was created successfully, the member can log in(sign in) to their own account. Once the member login, it will redirect to the main Home or Dashboard page. Moreover, the member can logout(session destroy) from his admin panel. This Full system we are developed using PHP and MySQL.
Furthermore, i will learn you how to build secure pages that are only accessed by logged in users. Without any types of the login, the member can not access the page.
How to create a Registration and Login System with PHP and MySQL
Here are Seven Basic simple steps you have to follow to create a login system & registration and login form in php and mysql with validation code free download.
Also Read: JQuery Ajax Secure Login Registration System In PHP And MySQL
- Create a MySQL Database and Database Table
- Simple Connect to the Database
- Session Create for Logged in User
- Create a Registration and Login Form
- Make a Dashboard Page
- Create a Logout (Destroy session)
- CSS File Create
Create a Database and Database Table
First of all, you have to log in to PHPMyAdmin. And then, click on the MySQL Database tab to create a new database. And then Enter your database name as well as click on create database button. As soon as PHPMyAdmin will create a new database.
Similarly, you can execute the below query to create a database.
CREATE DATABASE member_master;
Once you create a database, the second step to creating a member table. The member’s table will have the following fields.
- id – int(11)
- membername – varchar(100)
- email – varchar(100)
- password – varchar(100)
- created_at – datetime
CREATE TABLE IF NOT EXISTS `members` ( `id` int(11) NOT NULL AUTO_INCREMENT, `membername` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, `password` varchar(50) NOT NULL, `created_at` datetime NOT NULL, PRIMARY KEY (`id`) );
Copy the above query and execute it in the SQL query area.
Connect to the Database
After creating the table, i have to create a PHP MySQL connector script to connect to the MySQL database server. Create a file named db.php and put the following code inside it.
db.php
Session Create for Logged in User
Next, i have to create a session for the member. here simply Create a file named auth_session.php and paste the codes below.
auth_session.php
Creating a Registration Form
Furthermore, create PHP file registration.php as well as paste the following example code in it. This will create an HTML form. It will allow members to register.
registration.php
Registration - www.pakainfo.com You are registered successfully.
Click here to Login