Make the login button a part of a form, and have the form submit to index.php. The form will contain an empty input that tells the page that you have been logged out. For example:
<form action = "https://stackoverflow.com/" method = 'post'>
<input style="display: none;" name="logout" value="logoutTrue">
<input type = "submit' value="Logout">
</form>
Next, a simple if statement to check if you have been logged out:
<?php
if (isset($_POST['logout'])) {
$logoutVal = $_POST['logout'];
if ($logoutVal === "logoutTrue") {
header("Location: http://localhost/login.php");
}
}
?>
Uh, this should work, I think? If it doesn’t please post the error codes.
0
solved PHP Local host running errors [closed]