Search This Blog

Friday, May 3, 2013

Simple Php Login page with Database

Welcome to Designers Dairy blog here i have posted How to create a  Simple Php Login page

without Database

Step 1:  Create Login .html  and save

Login.html


<form action='logins.php' method='post'>

                  Username : <input type='text' name='username'> <br/>

                  Password : <input type='password' name='pass'> <br/>

                                       <input type='submit' value='Login'>

            </form>


Step 2: Create Login .php and save

Login.php

<?php

   //connecting to database

   $db = mysql_connect("localhost","root","") or die(mysql_error());


   //selecting our database

   $db_select = mysql_select_db("login", $db) or die(mysql_error());

   //Retrieving data from html form

  $username = $_POST['username'];

   $password = $_POST['pass'];




   //for mysql injection (security reasons)

   $username = mysql_real_escape_string($username);

   $password = mysql_real_escape_string($password);



   //checking if such data exist in our database and display result

   $login = mysql_query("select * from user where USERNAME = '$username' and

   PASSWORD = '$password'");

   if(mysql_num_rows($login) == 1) {

      echo "Login Successfull";
     
 header('Location: booked.html');
   

   }

   else {

      echo "Username and Password does not Match";

   }

?>


Step3 :  Have A fun.............!

No comments:

Post a Comment

Validating to select in sequencial order using angular

    < input type = "checkbox" (change) = "handleSelectTaskItem($event, taskItem)" [checked] = " taskItem . i...