PHP login script without using database
<p>I use PHP code below for login without using database.<br>
It redirects to home.php in two cases:<br>
1. When I input correct username and password<br>
2. <strong>When I input any character/s as username (except real username) and leave password textbox blank.</strong>  </p>

<p>In other cases, except the second, code works properly.<br>
How to make the code work properly in the second case?</p>

<pre><code>&lt;?php
 session_start();

$userinfo = array(
                'user1'=&gt;'pass1',
                );

if(isset($_GET['logout'])) {
    $_SESSION['username'] = '';
    header('Location:  ' . $_SERVER['PHP_SELF']);
}

if(isset($_POST['username'])) {
    if($userinfo[$_POST['username']] == $_POST['password']) {
        $_SESSION['username'] = $_POST['username'];

        header('Location: home.php');
    }else {
        header('Location: login.php');
    }   
}
?&gt;
</code></pre>
