Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Masuk(){
- try{
- Mysqlkoneksi kon = new Mysqlkoneksi();
- Connection con = kon.getConnection();
- Statement st = con.createStatement();
- String sqllogin = "SELECT * FROM user WHERE username='"+txt_username.getText()+"'";
- ResultSet rs = st.executeQuery(sqllogin);
- String sql_username = null;
- String sql_password = null;
- if(rs.next()){
- sql_username = rs.getString("username");
- sql_password = rs.getString("password");
- if(sql_username.equals(txt_username.getText())&&sql_password.equals(txt_passwd.getText())){
- JOptionPane.showMessageDialog(this, "Berhasil masuk");
- this.setVisible(false);
- }else
- {
- JOptionPane.showMessageDialog(this, "USERNAME atau PASSWORD anda salah"," PERINGATAN ", JOptionPane.ERROR_MESSAGE);
- }
- }
- else{
- JOptionPane.showMessageDialog(this, "USERNAME atau PASSWORD anda salah"," PERINGATAN ", JOptionPane.ERROR_MESSAGE);
- }
- rs.close();
- con.close();
- }catch(SQLException e){
- JOptionPane.showMessageDialog(null, "USERNAME atau PASSWORD anda SALAH", "PESAN", JOptionPane.ERROR_MESSAGE);
- }
- }
- void Kosong(){
- if(txt_username.getText().equals("")){
- JOptionPane.showMessageDialog(this, " USERNAME atau PASSWORD belum diisi", "PESAN", JOptionPane.ERROR_MESSAGE);
- }else if(txt_passwd.getPassword().equals("")){
- JOptionPane.showMessageDialog(this, " USERNAME atau PASSWORD belum diisi", "PESAN", JOptionPane.ERROR_MESSAGE);
- }else{
- Masuk();
- }
- }
Add Comment
Please, Sign In to add comment