Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Sample1.

php

<?php
session_start();
$pword=$_SESSION['psword'];
echo 'Your password is '.$pword;
$t_out = 10;

if(isset($_SESSION["timeout"])){
echo 'time out: '.$_SESSION['timeout'];
$sessionTTL = time() - $_SESSION["timeout"];
echo 'time to leave: '.$sessionTTL;
if($sessionTTL > $t_out){
session_destroy();
header("Location: login1.php");
}
}
$_SESSION["timeout"]=time();
?>

Login.php
<html>
<head><title> Log-In</title> </head>
<body>
<form method='POST'>
<input type='text' name='uname' placeholder='username' '><br><br>
<input type='password' name='pword' placeholder='password' ><br><br>
<input type='submit' name='submit' value='LOG IN'>
</form>
</body>
</html>
<?php
session_start();
if(isset($_POST['submit']))
if($_POST['pword']=='marcelo' AND $_POST['uname']=='erwin'){
$_SESSION['psword']=$_POST['pword'];
echo("
<script>
alert('Log In Successfull!');
window.location = 'sample1.php';
</script>
");
}
else{
echo("
<script>alert('Invalid Username/Password!');
</script>
");
}

?>

You might also like