<?php
if(isset($_POST['sub'])){
$uname = $_POST['txtuname'];
$pwd = $_POST['txtpwd'];
if($uname=="scott" and $pwd=="scott123"){
session_start();
$_SESSION['aut'] = true;
echo "<script>location='welcome.php';</script>";
}
else{
echo "invalid";
}
}
?>
<form method="post" action="">
Username:<input type="text" name="txtuname">
Password:<input type="password" name="txtpwd">
<input type="submit" name="sub" value="login">
</form>
WELCOME.PHP
<?php
session_start();
if(isset($_SESSION['aut'])){
echo "Welcome to user";
}
else{
echo "<script>location='login.php';</script>";
}
?>
<a href="logout.php">Logout</a><link rel="canonical" href="">
LOGOUT.PHP
<?php
session_start();
session_destroy();
echo "Logout successful";
?>
Sessions Login Logout
Like This Post? Please share!
0 comments:
Post a Comment