private void login_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_login_buttonActionPerformed
String nameuser=namet.getText().trim();
String password=pass.getText().trim();
try{
                        Class.forName("java.sql.DriverManager");
                        Connection con=(Connection)
                                DriverManager.getConnection("jdbc:mysql://localhost:3306/snudirectory",
                                "root", "prerna");
                        Statement stmt = (Statement) con.createStatement();

                        String query="SELECT Name,Email,passowrd,type FROM login WHERE name='"+nameuser+"' OR Email='"+nameuser+"';";
                        ResultSet rs=stmt.executeQuery(query);
int count=0;
                        while(rs.next()){
                           count++;
                           String name = rs.getString("Name");
                            String email = rs.getString("Email");
                            String passw=rs.getString("passowrd");
                            String type=rs.getString("type");
                            if(!passw.equals(password)){ JOptionPane.showMessageDialog(null,"Enter the correct username/password");}
else {if(passw.equals(password)){
                            if(type.equals("student"))
{Students s=new Students();
 s.setVisible(true);
}
if(type.equals("fac")){facnew s=new facnew();
 s.setVisible(true);}}
if(type.equals("par")){Parents s=new Parents();
 s.setVisible(true);}
                        }}

                            if(count<=0){JOptionPane.showMessageDialog(null,"Enter the correct username");}
                            }
catch (Exception e) {
                            JOptionPane.showMessageDialog(this, e.getMessage());
                        }
// TODO add your handling code here:
    }//GEN-LAST:event_login_buttonActionPerformed