session_start();
$user= $_GET['user'];
$password = $_GET['password'];
if ($user && $password)
{
  try
  {
    login($user,$password);
     
    $_SESSION['valid_user'] = $user;
  }
  catch(Exception $e)
  {
    
    
    echo 'You could not be logged in. 
          You must be logged in to view this page.';
    
   
    exit;
  }      
}function login($user, $password)
 
{
 
  
  $link= mysql_connect('localhost','root','225201')or die('could not connect:'.mysql_error());  mysql_select_db('forum') or die('could not select database');
   
   $result =mysql_query("select * from forum 
                         where user='$user'
                         and passward = sha1('$password')");
  
   if (!$result)
     throw new Exception('Could not log you in.');
  
  if (mysql_num_rows($result)>0)
     return true;
  else 
     throw new Exception('Could not log you in.');
}
我一用sha1()加密后,登录老提示'You could not be logged in. 
          You must be logged in to view this page这个错误。不用sha1就可以了。求助