After logging in with the correct username and password, I'm not sure how to get it to return back to the form once clicking on the logout button? I have written the following code:
<?php
session_save_path('/home/sarahmanchester/session');
session_start();
if(!isset($_SESSION['activitylog'])){
$_SESSION['username'] = 'Admin';
$_SESSION['password'] = 'pass';
}
$DisplayForm = True;
if(isset($_POST['username']) && ($_POST['password'])){
if(($_SESSION['username'] == $_POST['username']) &&
($_SESSION['password'] == $_POST['password'])){
echo 'Logged in!';
echo '<BR>';
echo 'Protected content will be displayed here.';
echo '<BR>';
echo '<input type="Submit" name="Submit" value="Logout">';
$DisplayForm = False;
echo '<HR>';
} else{
echo 'Error: Incorrect password.';
}
}
if ($DisplayForm){
echo '<form method="POST" action="'.$_SERVER['sample800.php'].'">';
echo '<h1>Login demo</h1>';
echo '<BR>';
echo 'Username: ';
echo '<input type="username" name="username">';
echo '<BR>';
echo 'Password: ';
echo '<input type="password" name="password">';
echo '<BR>';
echo '<input type="Submit" name="Submit" value="Login">';
echo '</form>';
}
?>