Skip to main content

How Create Login Page with Database and Session Module In PHP

*  Create Login Page With Database *

-> First Download Wamp Server or Xamp Server and Setup Your Drive And Check Avaiblity Of Xamp or Wamp.

-> Create Database in mysql database. and Create New Table and Insert New Record Like User name, Password, Full name, And extra Details....

-> and next Step is Create new page login.php or index.php

-> Write Code on Creating File.

->Establish Connection of Your Databse.

->create new file like config or connection... like(dbuser,dbpassword, and connection details..)

->The Following Code write in your index or Login Page.


<?php

    //old path

    //include('config/connection.php');

    //new path

    include('../../db/connection.php');

    if(isset($login))

    {

        $str="select*from admin where status='active' and user_name='$username' and password='$password';";

        $data=mysqli_query($conn,$str);

        $search=mysqli_num_rows($data);

        if($search>0)

        {

            $_SESSION['user_name']=$username;

            ?><script>window.location='<?php echo $domain_path; ?>dashboard.php';</script><?php

        }

        else

        {

           $error="Incorrect Username or Password...";

        }

    }

?>


Comments

Popular posts from this blog

How To Declare Variable and hello word in php ?

    Hii Guys Today We are Talking about of php variable Declaration and sinple print message and calculate simple sum of two numbers. php is very powerfull language to compare other language. so. lests start and see full tutorial. 1.0 Start PHP           * PHP code always start <?php word throw start and close php code ?> keyword. the following                          syntax throw start php working.                         ------------------------------------------------------------------------------                        |              <?php // start php                                   ...

What Is Java How to start Java programming ??

-> there are following feature are required to learn java. * Basic introduction of mysql database. DBMS     (DATABASE  MANAGEMENT  SYSTEM)   : The conventional file processing system had many drawbacks. Hence, an alternate system,   i.e.   database system, which was based on database approach, was desired because it would eliminate all the drawbacks of conventional file processing system. To define the database system   following terms are required:          FILE          DATABASE          DATABASE MANAGEMENT SYSTEM     File is a two dimensional table summarizing the multiple instances of asset of field of an entity. Database is a collection of interrelated data files, while database management system is a computer program that allows storing, organizing and accessing a collection...

How To Insert, Update, Delete Record on Mysql Database In PHP

  1.Insert Query $sql = "INSERT INTO persons (first_name, last_name, email) VALUES              ('Peter', 'Parker', 'peterparker@mail.com')" ; if ( mysqli_query ( $link , $sql ) ) { echo "Records inserted successfully." ; } else { echo "ERROR: Could not able to execute $sql . " . mysqli_error ( $link ) ; } 3.Update Query $sql = "UPDATE persons SET email='peterparker_new@mail.com' WHERE id=1" ; if ( mysqli_query ( $link , $sql ) ) { echo "Records were updated successfully." ; } else { echo "ERROR: Could not able to execute $sql . " . mysqli_error ( $link ) ; } 3.Delete Query $sql = "DELETE FROM persons WHERE first_name='John'" ; if ( mysqli_query ( $link , $sql ) ) { echo "Records were deleted successfully." ; } else { echo "ERROR: Could not able to execute $sql . " . mysqli_error ( $link ) ; } * ...