Content.php
<?php
session_start();
if(!isset($_SESSION['usr']) || !isset($_SESSION['pswd'])){
header(“Location: Form.php”);
}
include ‘logoff.html’;
<!– in this example my content only containing a html with logout link–>
?>
-----------------------------------------------------------------------------
Logout.php
<?php
session_start();
session_destroy();
header(‘Location: Form.php’);
exit;
?>
-----------------------------------------------------------------------------------------
form.php
<?php
session_start();
if(isset($_SESSION['usr']) && isset($_SESSION['pswd'])){
header(“Location: content.php”);
}
?>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<head>
<title> PHP Login </title>
</head>
<body>
<center>
<form method=”post” action=”login.php”>
<!– in this example I link it with login.php to check the password & username–>
<table>
<tr><td>Username:</td><td><input type=”text” name=”usr”></td></tr>
<tr><td>Password:</td><td><input type=”password” name=”pswd”></td></tr>
<tr><td><input type=”submit” name=”login” value=”Login”></td>
<td><input type=”reset” name=”reset” value=”Reset”></td></tr>
</table>
</form>
</center>
</body>
</html>
-----------------------------------------------------------------------
loggoff.php
<html>
<head>
<title></title>
</head>
<body>
<center>
<h2><a href=”./logout.php”>Logout</a></h2>
<br/>
</center>
</body>
</html>
---------------------------------------------------------------------
login.php
<?php
session_start();
if($_REQUEST['usr']==”ABC” && $_REQUEST['pswd']==”123″){
$_SESSION['usr'] = "ABC”;
$_SESSION['pswd'] = “123″;
header(“Location: content.php”);
}
else{
header(“Location: Form.php”);
}
?>
------------------------------------------------------------
Enjoy........................... :)
<?php
session_start();
if(!isset($_SESSION['usr']) || !isset($_SESSION['pswd'])){
header(“Location: Form.php”);
}
include ‘logoff.html’;
<!– in this example my content only containing a html with logout link–>
?>
-----------------------------------------------------------------------------
Logout.php
<?php
session_start();
session_destroy();
header(‘Location: Form.php’);
exit;
?>
-----------------------------------------------------------------------------------------
form.php
<?php
session_start();
if(isset($_SESSION['usr']) && isset($_SESSION['pswd'])){
header(“Location: content.php”);
}
?>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<head>
<title> PHP Login </title>
</head>
<body>
<center>
<form method=”post” action=”login.php”>
<!– in this example I link it with login.php to check the password & username–>
<table>
<tr><td>Username:</td><td><input type=”text” name=”usr”></td></tr>
<tr><td>Password:</td><td><input type=”password” name=”pswd”></td></tr>
<tr><td><input type=”submit” name=”login” value=”Login”></td>
<td><input type=”reset” name=”reset” value=”Reset”></td></tr>
</table>
</form>
</center>
</body>
</html>
-----------------------------------------------------------------------
loggoff.php
<html>
<head>
<title></title>
</head>
<body>
<center>
<h2><a href=”./logout.php”>Logout</a></h2>
<br/>
</center>
</body>
</html>
---------------------------------------------------------------------
login.php
<?php
session_start();
if($_REQUEST['usr']==”ABC” && $_REQUEST['pswd']==”123″){
$_SESSION['usr'] = "ABC”;
$_SESSION['pswd'] = “123″;
header(“Location: content.php”);
}
else{
header(“Location: Form.php”);
}
?>
------------------------------------------------------------
Enjoy........................... :)
Thanks Dear :)
ReplyDelete