title: login page error in php
body: <p>i m creating login page in php, but some error in it. when i enter wrong username or password then blank window is coming error messages are not and when both fields are empty then error messages are show.</p>
  
  <p>this is login page code</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  session_start();
  if(isset($_POST['submit']))
  {
    mysql_connect('localhost','root','') or die(mysql_error());
    mysql_select_db('ganga_hms') or die(mysql_error());
     
   $login_type=mysql_real_escape_string($_POST['login_type']);
   $username=mysql_real_escape_string($_POST['username']);
   $password=mysql_real_escape_string($_POST['password']);
   
    if($username!=''&amp;&amp;$password!='')
    {
  
    $query="SELECT username, password, account_type FROM login WHERE username='$username'and password='$password' and account_type='$login_type'";
    $sql=mysql_query($query) or die(mysql_error());
    $rows=mysql_num_rows($sql)or die(mysql_error());
    
    if($rows==1)
    {
     $_SESSION['user_id'] = $row[0];
     $_SESSION['username']=$username;
     $_SESSION['login_type']=$login_type;
     header('location:first_index.php');
      
    }
    else
    {
      echo "&lt;script type='text/javascript'&gt;alert('Plz enter correct username or password');&lt;/script&gt;";
      header('location:index.php');
    } 
    }
    else
   {
    
    echo "&lt;script type='text/javascript'&gt;alert('enter username or password');&lt;/script&gt;";
    echo "&lt;meta http-equiv='refresh' content='0;url=index.php'&gt;"; 
    }
  }
  ?&gt;</code></pre>
  </div>
  </div>
  </p>