This is my code:
   <?php
    $host="localhost";
    $user="root";
    $pass="";
    $db="comportal";
    mysql_connect($host, $user,$pass);
    mysql_select_db($db);
    if(isset($_POST['username'])){
    $username=$_POST['username'];
    $password=$_POST['password'];
    $sql="SELECT * FROM user WHERE username='".$username."' AND password='".$password."' LIMIT 1";
    $res= mysql_query($sql);
    if(mysql_num_rows($res)==1){
      echo "Successfully logged in.";
      exit();
     }
     else{
       echo "Invalid Information. Please return to the previous page.";
       exit();
     }
    }
    ?>
and I always get this error:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\sample\login.php on line 20
Invalid Information. Please return to the previous page.
Then I tried changing
  if(mysql_num_rows($res)==1){
  echo "Successfully logged in.";
  exit();
with
  if($res==true){
  echo "Successfully logged in.";
  exit();
But, now it's logically wrong. it says successfully logged in even though that is not stored in the database.
please how could I resolve that?