hacker_yusu

registration

Jul 14th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.72 KB | None | 0 0
  1. public void registration(){
  2. String str1 = R_N.getText();
  3. String str2 = R_CN.getText();
  4. String str3 = R_EI.getText();
  5. String str4 = R_A.getText();
  6. String str5 = R_U.getText();
  7. char[] pwd = R_P.getPassword();
  8. String s = new String(pwd);  //converting char to string
  9. String p = s;
  10. char[] pw = R_RP.getPassword();
  11. String f = new String(pw);  //converting char to string
  12. String l = f;
  13. Connection conn=null;
  14. PreparedStatement ps=null;
  15.  
  16. if("".equals(str1)){
  17.        JOptionPane.showMessageDialog(null, "Name is Empty", "Registration Status", JOptionPane.ERROR_MESSAGE);  
  18.      }
  19.        else if("".equals(str2)){
  20.        JOptionPane.showMessageDialog(null, "Contact Number is Empty", "Registration Status", JOptionPane.ERROR_MESSAGE);  
  21.      }
  22.        else if("".equals(str3)){
  23.        JOptionPane.showMessageDialog(null, "Email ID is Empty", "Registration Status", JOptionPane.ERROR_MESSAGE);  
  24.      }
  25.        else if("".equals(str4)){
  26.        JOptionPane.showMessageDialog(null, "Address is Empty", "Registration Status", JOptionPane.ERROR_MESSAGE);  
  27.      }
  28.        else if("".equals(str5)){
  29.        JOptionPane.showMessageDialog(null, "User Name is Empty", "Registration Status", JOptionPane.ERROR_MESSAGE);  
  30.      }
  31.      
  32.         else if((p.length()) == 0)
  33.           {
  34. JOptionPane.showMessageDialog(null, "Password is Empty", "Registration Status", JOptionPane.ERROR_MESSAGE);
  35.             }
  36.         else if((l.length()) == 0)
  37.           {
  38. JOptionPane.showMessageDialog(null, "Retype the password", "Registration Status", JOptionPane.ERROR_MESSAGE);
  39.             }
  40.         else if(p.equals(l))
  41.           {
  42.               try{
  43.             Class.forName("com.mysql.jdbc.Driver");
  44.             conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/hotel","root","root");
  45.             Statement stmt=conn.createStatement();
  46.             ps=conn.prepareStatement("insert into details values(?,?,?,?,?,?,?)");
  47.             ps.setString(1, str5);
  48.             ps.setString(2, p);
  49.             ps.setString(3, str1);
  50.             ps.setString(4, str2);
  51.             ps.setString(5, str3);
  52.             ps.setString(6, str4);
  53.             ps.setString(7, str6);
  54.             int i=ps.executeUpdate();
  55.             if(i>0){
  56.                 JOptionPane.showMessageDialog(null, "Registration Successful", "Registration Status", JOptionPane.INFORMATION_MESSAGE);
  57.                 R_N.setText("");
  58.                 R_CN.setText("");
  59.                 R_EI.setText("");
  60.                 R_A.setText("");
  61.                 R_U.setText("");
  62.                 R_P.setText("");
  63.                 R_RP.setText("");
  64.                 int reply = JOptionPane.showConfirmDialog(null, "Please Login", "Registration Status", JOptionPane.OK_OPTION);
  65.                
  66.                 if (reply == JOptionPane.OK_OPTION)
  67.                 {
  68.                  
  69.                 }
  70.                
  71.                 else
  72.                 {
  73.                     while(reply == JOptionPane.NO_OPTION){
  74.                      reply = JOptionPane.showConfirmDialog(null, "Please Login", "Registration Status", JOptionPane.OK_OPTION);  
  75.                      if (reply == JOptionPane.OK_OPTION)
  76.                 {
  77.                  
  78.                     }
  79.                 }
  80.                
  81.             }
  82.             }
  83.                 else{
  84.            JOptionPane.showMessageDialog(null, "Registration Unsuccessful.Check Internet or contact us.", "Registration Status", JOptionPane.ERROR_MESSAGE);
  85.               }
  86.             }
  87.               catch(Exception e){
  88.                  JOptionPane.showMessageDialog(null, e);
  89.               }
  90.               }
  91.         else{
  92.             JOptionPane.showMessageDialog(null, "Password Doesnot Match", "Login Status", JOptionPane.ERROR_MESSAGE);
  93.         }
  94. }
Add Comment
Please, Sign In to add comment