Ciao e grazie.

Queste sono le tre pagine che utilizzo, dove dovrei inserire l' "if"?

login
codice:
<?php
    session_start();
    unset($_SESSION["collegato"]);
    $user=trim($_POST["username"]);
    $pwd=trim($_POST["password"]);
    $mex="";
    if($user!=""&&$pwd!="")
    {
        if ($user=="utente"&&$pwd=="password")
        {
            $_SESSION["collegato"]="si";
            header("location: index.php");
            die("...Attendere, prego...");
        }
        else $mex="<br />Errore: Username o Password errate!<br /> <br />";
    }
?>
<html>
<head>
    <title>Area riservata</title>
</head>
<body>
<strong>Login</strong>
<br />
<?php if($mex!="") echo $mex;?>
<form method="post" action="login.php" enctype="multipart/form-data">
Username: <input type="Text" name="username" maxlength="20" size="10" />
<br />
Password: <input type="Password" name="password" maxlength="20" size="10" />
<br />
<input type="Submit" value="Entra" />
</form>
</body>
</html>
verifica
codice:
<?php
    session_start();
    if(trim($_SESSION["collegato"])!="si")
    {
        header("location: login.php");
        die("...Attendere, prego...");
    }
?>
e il codice nelle pagine
codice:
<?php include("verifica.php");?>
<html>
<head>
    <title>Area riservata</title>
</head>
<body>
--- contenuto da loggao ---
<br />
<a href="login.php">Logout</a>
</body>
</html>