Press "Enter" to skip to content

Change password code of library management system.

Why we change password ?

We change our password for some reasons.

  1. When we feel insecure our account .
  2. Forgot our password and
  3. Safe from any kind of hacking.

So, i think change password is very important of any kind of account.

To get help you can see the video.

Source code for forgot password page.

  1. Connect with connection class

Connection con = null;
ResultSet rs;
PreparedStatement pst;

public ChangePass() {
initComponents();
con = Connect.dbConnect();
middle();
}

public void middle(){
setLocationRelativeTo(null);
}

2. Change password…
try{
String sql = "select * from admin where email = '"+jTextField_oldUserName.getText()+"' and password='"+jPasswordField_OldPass.getText()+"' ";
pst = con.prepareStatement(sql);
rs = pst.executeQuery();
if(rs.next()){
String getId = rs.getString("id");
String NUEmail = jTextField_NewPass.getText();
String NUPass = jPasswordField_NewPass.getText();
if(jTextField_NewPass.getText().equals("") || jPasswordField_NewPass.getText().equals("")){
JOptionPane.showMessageDialog(null, "Fields Must Not Empty...!!!");
}else{
String query = "update admin set email='"+NUEmail+"', password='"+NUPass+"' where id='"+getId+"' ";
pst = con.prepareStatement(query);
pst.execute();
JOptionPane.showMessageDialog(null, "Updated Successfully...!!!");
}
}else{
JOptionPane.showMessageDialog(null, "Wrong Email or Password...!!!");
}
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}

Interface of after run the change password page.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *