Simple Login Form Using PHP MYSQL

Simple Login Form Using PHP MYSQL

PHP, TUTORIALS, WEB

Simple Login Form Using PHP MYSQL




In this tutorial we are gonna learn how to create a complete Simple Login Form Using PHP MYSQL. Here We can register a new user and sign in with the user name and password. Here we use the legend web combination PHP and the MYSQL. Here we have to notice that Learning PHP is Priceless.
Today’s trending web world many of the sites are runs under the technology combination of PHP and MYSQL. So far every website we visits nowadays they requires the subscribers list which is also known as the register and login logic.
In this lesson we will gives you an assurance that you’ll learn the things like create a database and table in MYSQL through PHPMYADMIN   which is an GUI for the MYSQL. And also the logic to compare two values from the database and do some operations on it.
For this Simple Login Form Using PHP MYSQL we’ll start with create an register form. Here we using the very most popular CSS framework which is called as BOOTSTRAP. You can get you copy from here. This will reduce our work to design our pages.
Here we gives how we handle the index page and etc,
Step: 1   Create Folder Named Login or whatever you want in the c:/xampp/htdocs  . Here we named it as Login. And inside the folder place the bootstrap files and folders.
Simple Login Form Using PHP MYSQL
Step 2: Create Index Page
Index.php

And the result is looks like this,
Simple Login Form Using PHP MYSQL
As we learn in our PHP Essential Training series, we used various methods to passing values from one page to another page. And here want to pass our input values to login_validate.php file. So far, here we use the POST method and form controls to pass the values to the next page.




Here we initially place the login page as index page. Because we believe that the customer have our login, if they doesn’t have it then we can redirect them to the register page. Like we did at here,
Before going to the login_validate.php  file, let’s create another page which is the register.php  adds the new user with the database.
Step 3: Create Register Page

And the result is looks like this,
Simple Login Form Using PHP MYSQL
In this register page and also the index.php we didn’t write any of the logic to fetch data from the database. But we gives link to another page to tells the browser, go to this page and see the logic. Here we have two logic page for two above User Interfaces.
The First one is the insert.php which can add our new user with the database, and the second one is the login_validate.php, used for compare the user typed values and the value fetch from the database and then login or shows any of the error messages.
Step 4:   Create Insert.php

In the above Simple Login Form Using PHP MYSQL code we get store the query in a variable and executes the query from the previous page which can be taken by the one of the powerful value passing method POST.
And then it inserts the values into the database, and automatically increments the value by one. Because we create the table in a certain cases.
Step 5:   Create login_validate.php

In the above code we gives the defines how to retrieve data from the database table employee. In this example we use the mysql_fetch_array() function to retrieve data. You may use the mysql_fetch_row or some other relevant functions. But this one will gives some accuracy and reliable in the output.
Here it checks whether the password and the user name are correct as per in the database rows. Here all the characters are case sensitive. If the user name and password are correct then it shows some welcome message.




Or Else if either of the user name or password is correct then it shows “Sorry Your password or User Name is not matched” text.
Or finally if both of them are wrong then it redirects to the index.php. This is main logic we’ve been used almost in any of Simple Login Form Using PHP MYSQL.
One thing you may noticed or wondered how the database is connect with our project. Here is the main part to connect a database, for that we create a separate file called db.php.
Step 5:   Create db.php

The above code shows is connect the database and the tables with our project.
Now we can access the collection of the above operations and it’ll be bundled as Simple Login Form Using PHP MYSQL. In this tutorial you may learn something basic needs to create a login form. We will learn a lot more about the PHP features in the upcoming lessons.

Leave a Reply