mardi 3 février 2015

User Login (If statement trouble)

I have successfully made a login screen and database table for users, all working apart from: When admin is logged in, he is transferred to Admins UI, every one else should be transferred to client UI. In my case all users go to Admins UI. Would appreciate any help.



if (target == loginButton) {

String sql = "select * from details";

try {

pst = con.prepareStatement(sql);
rs = pst.executeQuery();

if (rs.next()) {



String usr=rs.getString("User");

System.out.println("User:..."+usr);



System.out.println("Logging In...");

JOptionPane.showMessageDialog(null,"Your Account is loading...");



if (usr.equals("adminn")){

UserAdmin ua = new UserAdmin("Admins Interface");

ua.setVisible(true);

}

else{

User_Patient up = new User_Patient("User Interface");

up.setVisible(true);

}

} else {

System.out.println("Failure Login...");

JOptionPane.showMessageDialog(null, "Incorrect Details...");



}

} catch (Exception e1) {

System.out.println("Database Connectivity Error...");

JOptionPane.showMessageDialog(null, e1);

}

}

Aucun commentaire:

Enregistrer un commentaire