codice:
?>php 
session_start(); 
if(isset($_POST['login']) AND $_POST['login'] != '' )  {

        $user = $_POST["login"];
        $pwd  = $_POST["pwd"];

        include ("mdb-database/way.php"); 

        $link = mysql_connect($db_host, $db_user, $db_pass);

        mysql_select_db($db_name);

        $rich = "SELECT nome , id , classe
                 FROM utenti
                 WHERE user = '$user' AND pwd = '$pwd' ";

         $query = mysql_query($rich, $link);
         $row   = mysql_num_rows($query);
         $riga  = mysql_fetch_object($query);

                if($row == 1){ 
                        $_SESSION['confermato'] = 1;
                        $_SESSION['utente'] = $riga->id;
                        $_SESSION['classe'] = $riga->classe;
                        $_SESSION['nome'] = $riga->nome;

                        header("location: gestione.php");
                        exit;
                        }
                              else  {
                                    header("location: index.htm");
                                    exit;
                                    }
}
  else  {
         header("location: index.htm");
         exit;
        }
?>