Skip to content
Advertisement

Why it will still appear “Incorrect account or password or user type” after I login successful? [closed]

I’ve tried but just can’t figure out why, thanks for helping if there is any solution for this JFrame.

if (userInfo != null ) {    
    JOptionPane.showMessageDialog(null, "LoginSuccessful");
    dispose();                  
    new ChooseRoomFrame(userInfo,UserRoomDetails,UserDao).setVisible(true);
}                   
if(Staff != null & rdbtnStaff.isSelected()){
    JOptionPane.showMessageDialog(null, "Login Successful");
    dispose();
    new StaffFrame(userInfo, UserRoomDetails,UserDao).setVisible(true);                 
}       
if(user.isEmpty() & pwd.isEmpty()){
    JOptionPane.showMessageDialog(null,"Please insert Username and Password");
}               
else if(user.isEmpty()){
    JOptionPane.showMessageDialog(null,"Please insert Username");
}
else if (pwd.isEmpty()){
    JOptionPane.showMessageDialog(null,"Please insert Password");
}   
else {
    JOptionPane.showMessageDialog(null, "Incorrect account or password or user type");
}

Advertisement

Answer

it seems an incorrect logic. try return in every situation.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement