corecodeschool.blogspot.com: How to create login logout system using php

Enter Keyword Hear for Search This Blog

Showing posts with label How to create login logout system using php. Show all posts
Showing posts with label How to create login logout system using php. Show all posts

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

Contact

Contact Core Code School Core Code School shares beginner-friendly tutorials on PHP, HTML, CSS, JavaScript, Java, SQL and Ubuntu. You can...