<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<!--[if lt IE 7 ]> <html class="no-js loading ie6 oldie" dir="ltr" lang="en-US"> <![endif]-->
<!--[if IE 7 ]> <html class="no-js loading ie7 oldie" dir="ltr" lang="en-US"> <![endif]-->
<!--[if IE 8 ]> <html class="no-js loading ie8 oldie" dir="ltr" lang="en-US"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js loading" dir="ltr" lang="en-US"> <!--<![endif]-->
<?php
session_start();
define( "USERNAME", "john" );
define( "PASSWORD", "secret" );
if ( isset( $_POST["login"] ) ) {
login();
} elseif ( isset( $_GET["action"] ) and $_GET["action"] == "logout" ) {
logout();
} elseif ( isset( $_SESSION["username"] ) ) {
displayPage();
} else {
displayLoginForm();
}
function login() {
if (isset( $_POST["username"] ) and isset( $_POST["password"] ) ) {
if ($_POST["username"] == USERNAME and $_POST["password"] == PASSWORD ){
$_SESSION["username"] = USERNAME;
session_write_close();
header ('Location: loginpage.php');
} else {
displayLoginForm ('Sorry, that username/password could not be found. Please try again.');
}
}
}
function logout()
{
unset( $_SESSION["username"] );
session_write_close();
header('Location: loginpage.php');
}
function displayPage(){
displayPageHeader();
?>
<p> Welcome, <strong > <?php echo $_SESSION["username"] ?>
</strong > ! You are currently logged in. </p >
<p> <a href= ” loginpage.php action=logout”> Logout </a> </p>
<?php
}
function displayLoginForm( $message="" )
{
displayPageHeader();
?>
<html>
<head>
<meta charset="UTF-8" />
<title>Student Registration-NPCS</title>
<meta name="description" content="Management Software National Pre Cadre High School" />
<meta name="keywords" content="HTML5, Wordpress" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="favicon.png" />
<link rel="apple-touch-icon" href="img/touch-icon.png" />
<link rel="image_src" href="img/touch-icon.png" />
<link rel="stylesheet" href="css/style.css" />
<script type='text/javascript' src='js/jquery.min.js'></script>
<script type='text/javascript' src='js/jquery.plugins.min.js'></script>
<script type='text/javascript' src='js/site.js'></script>
<!--[if IE]>
<script type="text/javascript" src="js/ie.js"></script>
<script type="text/javascript" src="js/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="border-header"></div>
<section id="header" class="container">
<header id="logo" class="grid3 col">
<hgroup>
<h1><a class="animated shake" href="index.html" rel="home" title="Main Page!"><img src="img/logo-gray-yellow.png" class="scale" width="180" height="67" alt="CleanGold"/></a></h1>
</hgroup>
</header>
<div class="sep sep-small"></div>
<span id="switch">Menu <strong>≡</strong></span>
</section>
<section id="content" class="container">
<a class="button big full-width gray animated shake">Management Control System</a>
</section>
<br>
<br>
<br>
<section id="content" class="container" align="center">
<div class="grid12 col" align="center" >
<?php
if ($message) echo '<p class="error">' .$message. '</p>';
?>
<form action=" loginpage.php " method="post" >
<div style='width: 30em;' >
<label for="username" > Username </label >
<input type="text" name="username" id="username" value="" />
<label for=”password" > Password </label >
<input type="password" name="password" id="password" value="" />
<div style="clear: both;" >
<input type="submit" name="login" value="Login" />
</div >
</div >
</form >
<?php
}
function displayPageHeader() {
?>
</div>
<?php
}
?>
please tell any one y wud it not logout