title: Unable to login and no error message
body: <p>I want to login, but I can't. The registration of users and passwords is ok but when I try to login nothing happens and no error message.</p>
  
  <p>This is the code in my index.php:</p>
  
  <pre><code>&lt;?php
  require_once("config.php");
  if (isset($_SESSION['username']) === FALSE){
  header('location:login.php');
  exit();
  }
  $where = "";
  $sql = "SELECT id,subject FROM notes LIMIT 30";
  $result = mysql_query($sql);
  ?&gt;
  </code></pre>
  
  <hr>
  
  <p>And this is the code for login.php file:</p>
  
  <pre><code>&lt;?php
  require_once("config.php");
  $message = '';
  $username = '';
  if ($_SERVER['REQUEST_METHOD'] == "POST") {
  $username = mysql_real_escape_string(trim($_POST['username']));
  $password = sha1($_POST['password']);
  
  $sql = "SELECT * from users 
  where username ='" . $username . "' 
  and password = '" . $password . "'";
  $result = mysql_query($sql);
  if (mysql_num_rows($result) &gt; 0) {
  $_SESSION['username'] = $username;
  header("location:index.php");
  } else {
  $message = "Unable to login.  Check your username and password and try again.";
  }
  }
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form method ="POST" action="login.php"&gt;
  &lt;?php
  if ($message != '') {
  echo $message;
  }
  ?&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;th&gt;username&lt;/th&gt;
  &lt;td&gt;&lt;input type="text" name="username" value ="&lt;?php echo $username; ?&gt;"/&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;th&gt;password&lt;/th&gt;
  &lt;td&gt;&lt;input type="password" name="password" /&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;input type="submit" value="Login"/&gt; &amp;nbsp; &lt;a href="registration.php"&gt; register &lt;/a&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>