Beginners login form development tutorial using PHP script and Mysql Database

Login form is used for  providing  the individual access the computer system.  Login form providing the the security for unauthorized access the website program and server.  Login form  is a process to identify the information into a  system  by a user. Login form providing  the security  our system and website data. Create the login form in HTML is very simple. In the login form below example we use two text fields username, password and login button.

Example

login_form.html

Following  HTML code for the login form.

<html>
    <body>
    <form  action='login_action.php' method='post'>
        <table>
            <tr>
                <td>User Name</td>
                    <td><input type = "text"  name=  "user_name"></td>
           </tr>
                                                                                 
           <tr>
                  <td>Password</td>
                  <td><input type = "password"  name = "password"></td>
                 </tr>
                    <tr>
                      <td><input type  = "submit"  name = "login" value = "Login"></td>
                   </tr>
        </table>
       </form>
     </body>
 </html>             



 Login form action will be performed using phpMyAdmin in managing MySql database.  MySQL  database is very popular open source  SQL database management system.  Firsly  we create the database in phpMyadmin.  After create the database create the table in Mysql database.  In the database table we create three fields id, user_name and  password. After create the table insert value in username and password. Your database is ready to use.

login_action.php

<?php
ob_start();
mysql_connect("localhost", "root", "password");
mysql_select_db("databasename");

if(isset($_POST['login']))
{
    $user_name  =  $_POST['user_name'];
    $password  =  $_POST['password'];
    $login =  "select * from tablename where user_name=       '$user_name' && password= '$password' ";
     $exe = mysql_query($login);
     $rows = mysql_num_rows($exe);

    if($rows == 1)                                                                             
    {
        echo "Login Successfully";
     }
    else
    {
        echo "Invalid Username/Password";
     }
}                                               
?>

  After create the HTML login form we create the login_action.php page. In the login action page
  firstly we start php script for connecting the database table using php  script. When user fill
  the user name and password text fields and click on login button.  The login_action.php page
  will be open.  If your username and password is true  login successfully message display on
  the your screen. If your username and password not matched invalid username and password
  message display on your screen.


 
 


Students Tech Life