Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void registration(){
- String str1 = R_N.getText();
- String str2 = R_CN.getText();
- String str3 = R_EI.getText();
- String str4 = R_A.getText();
- String str5 = R_U.getText();
- char[] pwd = R_P.getPassword();
- String s = new String(pwd); //converting char to string
- String p = s;
- char[] pw = R_RP.getPassword();
- String f = new String(pw); //converting char to string
- String l = f;
- Connection conn=null;
- PreparedStatement ps=null;
- if("".equals(str1)){
- JOptionPane.showMessageDialog(null, "Name is Empty", "Registration Status", JOptionPane.ERROR_MESSAGE);
- }
- else if("".equals(str2)){
- JOptionPane.showMessageDialog(null, "Contact Number is Empty", "Registration Status", JOptionPane.ERROR_MESSAGE);
- }
- else if("".equals(str3)){
- JOptionPane.showMessageDialog(null, "Email ID is Empty", "Registration Status", JOptionPane.ERROR_MESSAGE);
- }
- else if("".equals(str4)){
- JOptionPane.showMessageDialog(null, "Address is Empty", "Registration Status", JOptionPane.ERROR_MESSAGE);
- }
- else if("".equals(str5)){
- JOptionPane.showMessageDialog(null, "User Name is Empty", "Registration Status", JOptionPane.ERROR_MESSAGE);
- }
- else if((p.length()) == 0)
- {
- JOptionPane.showMessageDialog(null, "Password is Empty", "Registration Status", JOptionPane.ERROR_MESSAGE);
- }
- else if((l.length()) == 0)
- {
- JOptionPane.showMessageDialog(null, "Retype the password", "Registration Status", JOptionPane.ERROR_MESSAGE);
- }
- else if(p.equals(l))
- {
- try{
- Class.forName("com.mysql.jdbc.Driver");
- conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/hotel","root","root");
- Statement stmt=conn.createStatement();
- ps=conn.prepareStatement("insert into details values(?,?,?,?,?,?,?)");
- ps.setString(1, str5);
- ps.setString(2, p);
- ps.setString(3, str1);
- ps.setString(4, str2);
- ps.setString(5, str3);
- ps.setString(6, str4);
- ps.setString(7, str6);
- int i=ps.executeUpdate();
- if(i>0){
- JOptionPane.showMessageDialog(null, "Registration Successful", "Registration Status", JOptionPane.INFORMATION_MESSAGE);
- R_N.setText("");
- R_CN.setText("");
- R_EI.setText("");
- R_A.setText("");
- R_U.setText("");
- R_P.setText("");
- R_RP.setText("");
- int reply = JOptionPane.showConfirmDialog(null, "Please Login", "Registration Status", JOptionPane.OK_OPTION);
- if (reply == JOptionPane.OK_OPTION)
- {
- }
- else
- {
- while(reply == JOptionPane.NO_OPTION){
- reply = JOptionPane.showConfirmDialog(null, "Please Login", "Registration Status", JOptionPane.OK_OPTION);
- if (reply == JOptionPane.OK_OPTION)
- {
- }
- }
- }
- }
- else{
- JOptionPane.showMessageDialog(null, "Registration Unsuccessful.Check Internet or contact us.", "Registration Status", JOptionPane.ERROR_MESSAGE);
- }
- }
- catch(Exception e){
- JOptionPane.showMessageDialog(null, e);
- }
- }
- else{
- JOptionPane.showMessageDialog(null, "Password Doesnot Match", "Login Status", JOptionPane.ERROR_MESSAGE);
- }
- }
Add Comment
Please, Sign In to add comment