I am trying to make a PHP-program for users to create a new account. This snippet shows how I tried to check if the username is already in my Database. If not, it continues. If the name is already taken the second if-loop should show the informations to the user and the program stops saving it. My Problem is, that the program jumps always into the second if-loop, doesnt matter if the username is already taken or not. It nevers saves a new user into my database.
Thank for your help in advance!
if(!$error) {
    $statement = $db->prepare("SELECT * FROM zugangsdaten WHERE nutzerid = ?");
    $statement->bind_param("s", $nutzerid);
    $result = $statement->execute();
    $user = $statement->fetch();
    var_dump("USER:", $user);
    if($user !== false){
        echo 'Dieses Nutzer-ID ist bereits vergeben.<br>';
        echo 'Bitte andere Nutzer-ID wählen. <br>';     
        $error = true;  
    }
}
 
    