File No.1 LoginDesg.php -
<html> <head> <title>LoginDesg</title> </head> <body> <form id="form1" name="form1" method="post" action="LoginCode.php"> <table width="25%" align="center"> <tr> <th><div align="right">Username: </div></th> <td><input type="text" name="txtuname" id="txtuname" /></td> </tr> <tr> <th><div align="right">Password: </div></th> <td><input type="password" name="txtpass" id="txtpass" /></td> </tr> <tr> <th><div align="right">Remember me: </div></th> <td><input type="checkbox" name="chk" id="chk" /></td> </tr> <tr> <th><div align="right"> <input type="submit" class="btn" name="btnlogin" id="btnlogin" value="Login" /> </div></th> <td></td> </tr> </table> </form> </body> </html>
File No.2 -
<?php
$uname=$_REQUEST["txtuname"];
$pass=$_REQUEST["txtpass"];
if($uname=="test" && $pass==12345)
{
if(isset($_REQUEST["chk"]))
{
setcookie("uname",$uname,time()+60*60*24);
}
header("location:Account.php");
}
else
{
header("location:LoginDesg.php");
}
?>
File No. 3 -
<html>
<head>
<title>Account</title>
</head>
<body style="text-align:center">
<div>
<?php
$uname=$_COOKIE["uname"];
if(isset($_COOKIE["uname"]))
{
echo "You are logged in as $uname.";
}
else
{
echo "You entered here as a guest<p>";
}
?>
</div>
<h3>Member Area</h3>
<a href="ProtectedArea.php">Go to member area</a>
</body>
</html>
File No. 4 -
<?php
if(isset($_COOKIE["uname"]))
{
header("location:ProtectedArea.php");
}
else
{
header("location:LoginDesg.php");
}
?>
File No. 5 -
<?php
include("CheckLogin.php");
?>
<html>
<head>
<title>Protected Area</title>
</head>
<body style="text-align:center">
<h1>Welcome to protected area</h1>
</body>
</html>
Note -
Username is "test" and password is "12345";
In IE the page is loading and loading and in Firfox following msg appears -
PHP.JPG 73.75K
31 downloads


Sign In
Create Account


Back to top









