检查用户是否存在,然后使用PDO检查密码

I am trying to check if a users exists using PDO and after that if the password is correct, is there a way to make this work? Or do I need 2 queries?

$sql = "SELECT * FROM login WHERE user = :username AND password = :password";

$result = $statement->fetchAll();

<?php if (isset($_POST['submit']) && count($result["name"]) < 1) { ?>
    <div class="sticky-top alert alert-danger" role="alert"> <?= $username ?> could not be found. </div>    
<?php } ?>