Registration

Create Complete User Registration Form in PHP and MySQL

Do you want to create a complete user registration form in PHP and MySQL programming? and then this blog post is exactly for you. This article will show you how you can create a complete login and user registration system using PHP and MySQL programming. This tutorial includes the complete step-by-step process to create a user registration form in PHP and MySQL.

In addition, this tutorial also contains the source code of all the files to make a login and registration form in the PHP and MySQL databases. Similarly, there are many other server-side languages that we can use to create the store the user’s data and user registration details, but in this article, we are specifically using the PHP with MySQL database to create a simple user login and registration form in PHP.

What You Will Learn?

As stated previously, in this article, you are going to learn the following important concepts while creating the complete user registration form in PHP and using the MySQL database.

  1. How to create a user registration form in HTML and CSS?
  2. How to create a new MySQL database in PHPMyAdmin?
  3. How to connect with MySQL database with PHP?
  4. How to do registration form validation in PHP?
  5. Password encryption or password hashing in PHP?
  6. How to insert or update user data into the database table?
  7. How to use $_session variable in the PHP user registration and login form?
  8. How to set the cookies variable in PHP for user registration?
  9. How to create a User logout PHP code?
  10. How to create a user login system in PHP?
  11. How to write PHP code for the user login form?
Читайте также:  Kurtki54 ru catalog html

Video Tutorial – Login Register PHPO

Meanwhile, You can watch the following video tutorial which includes the step-by-step process to create a complete user registration form using PHP and MySQL databases.

Cpanel web hosting file manager to upload files

  • Make your computer a Local Server. Install a XAMPP application on your computer and place your PHP files inside the htdocs folder which is located at the following location on your computer.

C:\xampp\htdocs

After installation of XAMPP, you need to start the XAMPP control panel to run the PHP code on your local server. Start MySQL and Apache modules and wait for the green color indication to properly start the XAMPP local server.

XAMP control panel window

How to Create a new PHP Database with MySQL?

To create a complete registration and login form in PHP and MySQL first, you need to create a PHP Database and user table where you want to save the customer’s details. If You don’t know how to create the new PHP database in PHPMyAdmin then you can watch the below video tutorial.

Источник

Create a Registration and Login System with PHP and MySQL

Create a Registration and Login System with PHP and MySQL

How to create a Registration and Login System with PHP and MySQL. Here is the quick solution to build a login system with PHP and MySQL. Nowadays almost every website provides Registration and login functionality. Thus, it is necessary to add a login system in modern web applications.

In this tutorial, we walk through the complete process of creating a user registration system. Users can create an account by providing username, password, email. After the account was created, the user can log in to their own account. Once the user login, it will redirect to the Dashboard page. Moreover, the user can logout from his panel. This whole system we are developed using PHP and MySQL.

Furthermore, we will show you how to build secure pages that are only accessed by logged in users. Without login, the user can not access the page.

How to create a Registration and Login System with PHP and MySQL

Here are Seven pretty simple steps you have to follow to create a login system.

  1. Create a Database and Database Table
  2. Connect to the Database
  3. Session Create for Logged in User
  4. Create a Registration and Login Form
  5. Make a Dashboard Page
  6. Create a Logout (Destroy session)
  7. CSS File Create
Читайте также:  Чек лист php разработчика

Create a Database and Database Table

First, you have to log in to PHPMyAdmin. Next, click on the Database tab to create a new database. Enter your database name and click on create database button. As soon as PHPMyAdmin will create a new database.

Create new database in MySQL - Registeration and login system

Similarly, you can execute the below query to create a database.

CREATE DATABASE LoginSystem;

Once you create a database, the second step to creating a user table. The user’s table will have the following fields.

  • id – int(11)
  • username – varchar(100)
  • email – varchar(100)
  • password – varchar(100)
  • create_datetime – datetime
CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(50) NOT NULL, `email` varchar(50) NOT NULL, `password` varchar(50) NOT NULL, `create_datetime` datetime NOT NULL, PRIMARY KEY (`id`) );

Copy the above query and execute it in the SQL query area.

Create user table in MySQL database - Registeration and login system

Your database table looks like the below screen.

User table structure

Connect to the Database

After creating the table, we 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, we have to create a session for the user. 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 and paste the following example code in it. This will create an HTML form. It will allow users to register.

registration.php

       

You are registered successfully.


Click here to Login

"; > else < echo "

Required fields are missing.


Click here to registration again.

"; > > else < ?>

Registration

Click to Login

?>

The output of the above code will look like this.

Registration form - Registration and Login System

Creating a Login Form

Similarly, create a PHP file login.php and put the following example code in it. This file code contains a form that allows users to enter username and password.

login.php

       else < echo "

Incorrect Username/password.


Click here to Login again.

"; > > else < ?>

Login

New Registration

?>

Similarly, the output of the above code will look like this.

Login form

Making a Dashboard Page

Once user login we will redirect to the user dashboard page. Create a PHP file named dashboard.php and paste the below code in it.

dashboard.php
        

Hey, !

You are now user dashboard page.

Logout

After the user login, you will see the following user dashboard screen.

User dashboard screen - Registration and Login System

Similarly, you can create another secure page. Only you need to add the below code first in your PHP file.

Create a Logout (Destroy session)

When clicking on the logout button we have to destroy user sessions. It will redirect to the login page. Thus, create a file named logout.php and add the below code.

logout.php

CSS File Create

Finally, important step for a user experience perspective. Create CSS file style.css and put the below code.

style.php
body < background: #3e4144; >.form < margin: 50px auto; width: 300px; padding: 30px 25px; background: white; >h1.login-title < color: #666; margin: 0px auto 25px; font-size: 25px; font-weight: 300; text-align: center; >.login-input < font-size: 15px; border: 1px solid #ccc; padding: 10px; margin-bottom: 25px; height: 25px; width: calc(100% - 23px); >.login-input:focus < border-color:#6e8095; outline: none; >.login-button < color: #fff; background: #55a1ff; border: 0; outline: 0; width: 100%; height: 50px; font-size: 16px; text-align: center; cursor: pointer; >.link < color: #666; font-size: 15px; text-align: center; margin-bottom: 0px; >.link a < color: #666; >h3

Finally, our login system is ready to use. You can download the source code from the below download link.

Final Thoughts

That all you need to know how to create registration and login system in PHP with MySQL database. Furthermore, we create a registration and login form. Moreover, we create a MySQL connection file to establish a database connection. Thus we create a complete login system with interactive design.

We hope you have found this article helpful. Let us know your questions or feedback if any through the comment section in below. You can subscribe our newsletter and get notified when we publish new WordPress articles for free. Moreover, you can explore here other JavaScript related articles.

Источник

Оцените статью