Stworzenie prostego logowania

Proste fkcja przeprowadzajaca autorycazje i logowanie

function auth()
{

    $users = array(
        'admin' => 'haslo123'
    );

    // checking if user is not authenticated
    if (!isset($_SESSION['user_name']) || !isset( $users[$_SESSION['user_name']] ) || $_SESSION['user_passwd'] !== $users[$_SESSION['user_name']])
    {
        // if not, checking if he just authenticated
        // but we haven't processed that information yet
        if (isset($_POST["form_username"]))
        {
            $_SESSION['user_name']   = $_POST["form_username"];
            $_SESSION['user_passwd'] = $_POST["form_password"];
            header('Location: http://'.$_SERVER['HTTP_HOST'].'/admin?'.SID);
            exit;
        }

        echo 
'
<html><body>
<style>
td, th { font-size:12px; padding:4px 10px;}

</style>
<div style="width:450px;margin:auto;padding:60px 0 60px 0;text-align:center;">
<h1 style="font-size:16px;color:#f00;">Vacation Express Admin</h1>
<form method="post">
<table style="border:#666 solid 1px;margin:auto;">
<tr><th>Username: </th><td><input type="text"        name="form_username"></td></tr>
<tr><th>Password: </th><td><input type="password"    name="form_password"></td></tr>
<tr><td colspan="2" style="text-align:right"><input type="submit" value="Submit"></td></tr>
</form>
<table>

</div></body></html>';

        exit;
    }

}

wiecej info: http://www.digiways.com/articles/php/sessauth/