I wrote a function in PHP to check username and password from MySQL database and store as session after successful validation. But whatever value I enter to the input box it approves it and made a successful login. My Login code doesn't work
here it is
function queryByUserAndPass($tableName, $username, $password){
    $queryStatement = "SELECT * FROM ".$tableName." WHERE username='".$username."' 
                      AND password='".$password."' LIMIT 1";
    return $queryStatement;
}
function checkLogIn() {
    if(isset($_POST['submit'])){
        $username = $_POST['username'];
        $password = $_POST['password'];
        $queryState = queryByUserAndPass("nepal_users", $username, $password);
        if( $resultQuery = mysql_query($queryState) ){
            $found_user= mysql_fetch_array($resultQuery);
            $_SESSION['id']=$found_user['id'];
            $_SESSION['username']=$found_user['username'];
            $message="succesful log in ".$_SESSION['username'];
            header("location:home.php");
            exit;
        }else {
            $message="error in log in";
        }    
    }
}
Please tell me what is wrong in this code and why it is not working.
 
     
     
    