PHP MySQL Login Form

 PHP MySQL Login Form

In this tutorial you will learn how to build a login system with PHP and MySQL.

code here 

Implementing User Authentication Mechanism

User authentication is very common web application. It is a security mechanism that's used to restrict unauthorized access to member-only areas and tool on a site.

In this tutorial we'll create a simple registration and login system using the PHP and MySQL. This tutorial is comprised of two parts: in the first part we'll create a user registration form, and in the second part we'll create a login form, as well as a welcome page and a logout script.

Building the Registration System

In this section we'll build a registration system that allows users to create a new account by filling out a web form. But, first we need to create a table that will hold all the user data.

Step 1: Creating the Database Table

Execute the following SQL query to create the users table inside your MySQL database.

Example

CREATE TABLE users ( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, username VARCHAR(50) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP );

Please check out the tutorial on SQL CREATE TABLE statement for the detailed information about syntax for creating tables in MySQL database system.

Step 2: Creating the Config File

After creating the table, we need create a PHP script in order to connect to the MySQL database server. Let's create a file named "config.php" and put the following code inside it.


Comments

Popular posts from this blog

How to download Java | RJAVATech

Java | How to start Learning Java

JavaScript Basic