I have a prepared php statement to insert a row into my database. I have (what i consider) error checking along the way. At the end there is a check for an error on $stmt->execute(). If it returns false I want it to cancel the INSERT operation and show my message. The value is false but the INSERT is still successful. I had assumed if $stmt->execute()===false then there would be no INSERT into my database.
I apologize if this is a duplicate, I was having trouble finding a previous question similar to mine.
Here is the section causing the issue:
    $sql = "INSERT INTO login (username, password, name, branch, officer, type, alerts) VALUES (?, ?, ?, ?, ?, ?, ?)";
    $stmt = $nbadmin->prepare($sql);
    if(false===($nbadmin->prepare($sql))){
        $nbadmin->close();
        echo '<script>alert("Something went wrong; try again.")</script>';
        error();
    }
    $stmt->bind_param('sssssss', $user, $pass, $name, $branch, $officer, $type, $alert);
    if(false===($stmt->bind_param('sssssss', $user, $pass, $name, $branch, $officer, $type, $alert))){
        $nbadmin->close();
        echo '<script>alert("Something went wrong; try again.")</script>';
        error();
    }
    $stmt->execute();
    if(false===($stmt->execute())){
        $nbadmin->close();
        echo '<script>alert("Something went wrong; try again.")</script>';
        error();
    }else{
        $nbadmin->close();
        finish();
    }
function error(){
    header("Refresh: 0; url=../edit-user.php#user-form");
}
 
     
    