When I click on Logout link it redirects to an empty page.
Here is the Login.php
file:
<?php
session_start();
$_SESSION['logout']= 'username';
include_once('config.php');
if(isset($_POST['btn'])) {
$username = addslashes($_POST['username']);
$password = addslashes(md5($_POST['password']));
$query = mysqli_query($connect, "SELECT * FROM register WHERE username = '$username' AND password = '$password' ")
or die(mysql_error());
$result = mysqli_fetch_array($query);
if($result['username']==$username) {
echo "You have successfully loged in <br>";
$check = true;
}else {
echo "Wrong Login or Password <br>";
}
}
?>
<a href="logout.php">Logout</a>
Logout.php
file:
<?php
session_start();
if(isset($_POST['logout'])) {
session_destroy();
header("Location:login.html");
}
?>
Please can you correct my code and tell me what I've done wrong?