Protected Page – PHP

<?php
session_start();
 
if(isset($_GET['logout'])){
    session_destroy();
    header('Location: index.php');
    exit();
}
 
if(!isset($_SESSION['authorized']))
{
if(isset($_POST['submit'])){
    if($_POST['username'] =='user1' && $_POST['password'] == 'password1'){
        $_SESSION['authorized'] = true;
        header('Location: index.php');
        exit();
    }
}
 
?>
 
<form action='' method='post' autocomplete='off'>
<p>Username: <input type="text" name="username" value=""></p>
<p>Password: <input type="password" name="password" value=""></p>
<p><input type="submit" name="submit" value="Login"></p>    
</form>
 
<?php } else { ?>

PROTECTED CONTENT

<?php } ?>