Thursday 16 October 2014

Multiple way user login system like facebook

Facebook style multiple way user login system. this concept i explain about how user will login multiple way in website generally users want quick login website, if the login system its very flexible user will visit our page more time mshort period that is the reason facebook given multiple way login system.

facebook login






it should need 5 files for this login-logout system, they are
1.login/index page
2.datafetch/usercheck page
3.session/check page
4.welcome/profile page
5.logout page

Database

<?php 
      $db = new mysqli('localhost', 'root', '', '1next2');
 ?>

Index.php

<form method="post" name="login" action="login.php">
<label for="name" class="labelname"> Email or phone  </label>
<input type="text" name="user" id="userid" required="required" /><br />
<label for="name" class="labelname"> Password </label>
<input type="password" name="pass" id="passid" required="required"  /><br />
<input type="submit" name="submit" id="submit"  value="Login" />
</form>

Login.php

<?php 
include('db.php');
session_start();
{
    extract($_POST);
    $password=md5($pass);
    $fetch=$db->query("SELECT * FROM `users` WHERE '$user' IN (username,email,phone) AND `password` = '$password'");
    $count=mysqli_num_rows($fetch);
    if($count!="")
    {
       $row=mysqli_fetch_object($fetch);
       $_SESSION['login_username']=$row->username;    
       header("Location:profile.php");  
    }
    else
    {
       header('Location:index.php');
    }
}
?>

Session.php

<?php 
include('db.php');
session_start();
$check=$_SESSION['login_username'];
if(!isset($check))
{
    header("Location:index.php");
} 
?>

profile.php

<?php
include("session.php");
?>
<h3 align="center"> Hellow <?php echo $check; ?></h3> 
<h2 align="center" >Welcome to login system</h2> 
<h4 align="center">  click here to <a href="logout.php">LogOut</a> </h4>

logout.php

<?php
session_start();
if(session_destroy())
{
header("Location: index.php");
}
?>

10 comments:

© All rights reserved @ 1next2.com