Enter Keyword Hear for Search This Blog

Saturday, 23 April 2016

How to create login logout system using php

login.php

      <html>
<head>
</head>

<body>
<form action="login_pro.php" method="post">
      username<br />
     <input type="text" name="unm">
     <br />
     <br />
     password<br />
     <input type="password" name="pwd">
     <br />
     <br />
     <input type="submit" value="login">
                      </form>
</body>
      </html>


login_pro.php

<?php session_start();
if (empty($_REQUEST['unm']) || empty($_REQUEST['pwd']))
{
echo "pleace enter username and password";
}
else
{
$link=mysql_connect("localhost","root","");
mysql_select_db("login",$link);
$unm=$_REQUEST['unm'];
$pwd=$_REQUEST['pwd'];

$q="select * from registration where unm='$unm' and pwd='$pwd'";

$res=mysql_query($q,$link)or die($row);
$row=mysql_fetch_array($res);

if(empty($row))
{
echo"wrong username or password";
}
else
{
$_SESSION['unm']=$row['unm'];
$_SESSION['status']=true;
header("location:index1.php");
}
}
?>

index1.php

<?php session_start();
if(isset($_SESSION['status']))
{
echo 'hello:'.$_SESSION['unm'];
echo '<a href="logout.php">Logout</a>';
}
else
{
header("location:logout.php");
}
?>

logout.php

<?php session_start();
 session_destroy();

header("location:login.php");
?>

Featured post

what is ajax?how to create ajax with php code

Ajax Introduction -  એજેક્સ નો ઉપીયોગ કરી ને તમે પેજ લોડ કાર્ય વિના બધી માહિતી મેળવી શકો.એજેક્સ થી તમે કોઈ પણ ડેટા ઝડપ થી મેળવી શકો છો...