Why we change password ?
We change our password for some reasons.
- When we feel insecure our account .
- Forgot our password and
- 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.
-
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…3>
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.
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);
}
Be First to Comment