Repository navigation
Expand file tree
/
Copy pathsignup.java
More file actions
342 lines (299 loc) · 15 KB
/
Copy pathsignup.java
File metadata and controls
342 lines (299 loc) · 15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
package team;
import javax.swing.*;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.*;
import java.util.*;
/**
*
* @author risha
*/
public class signup extends javax.swing.JFrame {
/**
* Creates new form signup
*/
String fname, lname, password, uname, mail, mob;
int id=0;
public int getID() {
try {
ResultSet rs = null;
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/tms?zeroDateTimeBehavior=CONVERT_TO_NULL","root","Zebron1cs");
String sql = "select max(id) from signup";
Statement st = con.createStatement();
rs = st.executeQuery(sql);
while (rs.next()) {
id = rs.getInt(1);
id++;
}
}
catch (Exception e) {
e.printStackTrace();
}
return id;
}
public signup() {
initComponents();
this.setLocationRelativeTo(null);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
signuppassword = new javax.swing.JPasswordField();
username = new javax.swing.JTextField();
mobile = new javax.swing.JTextField();
emailid = new javax.swing.JTextField();
lastname = new javax.swing.JTextField();
firstname = new javax.swing.JTextField();
signupbutton = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel4.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
jLabel4.setForeground(new java.awt.Color(255, 255, 255));
jLabel4.setText("First Name:");
getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 170, 130, -1));
jLabel5.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
jLabel5.setForeground(new java.awt.Color(255, 255, 255));
jLabel5.setText("Last Name:");
getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 210, 130, -1));
jLabel6.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
jLabel6.setForeground(new java.awt.Color(255, 255, 255));
jLabel6.setText("Email ID:");
getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 250, 120, -1));
jLabel7.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
jLabel7.setForeground(new java.awt.Color(255, 255, 255));
jLabel7.setText("Mobile Number:");
getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 290, 190, -1));
jLabel8.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
jLabel8.setForeground(new java.awt.Color(255, 255, 255));
jLabel8.setText("Username:");
getContentPane().add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 330, 130, -1));
jLabel9.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
jLabel9.setForeground(new java.awt.Color(255, 255, 255));
jLabel9.setText("Password:");
getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 370, 130, -1));
signuppassword.setBackground(new java.awt.Color(221, 24, 24));
signuppassword.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
signuppassword.setForeground(new java.awt.Color(255, 255, 255));
signuppassword.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 2, 0, new java.awt.Color(255, 255, 255)));
getContentPane().add(signuppassword, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 380, 208, -1));
username.setBackground(new java.awt.Color(221, 24, 24));
username.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
username.setForeground(new java.awt.Color(255, 255, 255));
username.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 2, 0, new java.awt.Color(255, 255, 255)));
username.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
usernameActionPerformed(evt);
}
});
getContentPane().add(username, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 340, 208, -1));
mobile.setBackground(new java.awt.Color(221, 24, 24));
mobile.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
mobile.setForeground(new java.awt.Color(255, 255, 255));
mobile.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 2, 0, new java.awt.Color(255, 255, 255)));
getContentPane().add(mobile, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 300, 208, -1));
emailid.setBackground(new java.awt.Color(221, 24, 24));
emailid.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
emailid.setForeground(new java.awt.Color(255, 255, 255));
emailid.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 2, 0, new java.awt.Color(255, 255, 255)));
getContentPane().add(emailid, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 260, 208, -1));
lastname.setBackground(new java.awt.Color(221, 24, 24));
lastname.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
lastname.setForeground(new java.awt.Color(255, 255, 255));
lastname.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 2, 0, new java.awt.Color(255, 255, 255)));
lastname.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
lastnameActionPerformed(evt);
}
});
getContentPane().add(lastname, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 220, 208, -1));
firstname.setBackground(new java.awt.Color(221, 24, 24));
firstname.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
firstname.setForeground(new java.awt.Color(255, 255, 255));
firstname.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 2, 0, new java.awt.Color(255, 255, 255)));
getContentPane().add(firstname, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 180, 208, -1));
signupbutton.setBackground(new java.awt.Color(221, 24, 24));
signupbutton.setIcon(new javax.swing.ImageIcon("C:\\Users\\Paarth Jha\\Desktop\\Work\\Java\\Project\\References\\icons\\submit.png")); // NOI18N
signupbutton.setBorder(null);
signupbutton.setBorderPainted(false);
signupbutton.setContentAreaFilled(false);
signupbutton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
signupbuttonActionPerformed(evt);
}
});
getContentPane().add(signupbutton, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 430, 200, 100));
jButton1.setBackground(new java.awt.Color(221, 24, 24));
jButton1.setIcon(new javax.swing.ImageIcon("C:\\Users\\Paarth Jha\\Desktop\\Work\\Java\\Project\\References\\icons\\back.png")); // NOI18N
jButton1.setBorder(null);
jButton1.setBorderPainted(false);
jButton1.setContentAreaFilled(false);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 600, 170, 100));
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 56)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText("Sign Up");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 50, 220, 80));
jLabel10.setIcon(new javax.swing.ImageIcon("C:\\Users\\Paarth Jha\\Desktop\\Work\\Java\\Project\\References\\icons\\Pure Lust.jpg")); // NOI18N
jLabel10.setText("jLabel10");
getContentPane().add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 1030, 720));
pack();
}// </editor-fold>//GEN-END:initComponents
private void signupbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_signupbuttonActionPerformed
if(validation()) {
enterdetails();
}
}//GEN-LAST:event_signupbuttonActionPerformed
private void lastnameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lastnameActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_lastnameActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
new loginPage().setVisible(true);
this.dispose();
}//GEN-LAST:event_jButton1ActionPerformed
private void usernameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usernameActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_usernameActionPerformed
void enterdetails() {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/tms?zeroDateTimeBehavior=CONVERT_TO_NULL","root","Zebron1cs");
String sql = "insert into signup values(?,?,?,?,?,?,?)";
PreparedStatement stmt = con.prepareStatement(sql);
stmt.setInt(1, getID());
stmt.setString(2, fname);
stmt.setString(3, lname);
stmt.setString(4, mail);
stmt.setString(5, mob);
stmt.setString(6, uname);
stmt.setString(7, password);
int i = stmt.executeUpdate();
if (i>0) {
JOptionPane.showMessageDialog(this, "Account created successfully.");
}
else {
JOptionPane.showMessageDialog(this, "Account creation failed.");
}
}
catch (Exception e) {
e.printStackTrace();
}
}
boolean validation() {
fname = firstname.getText();
lname = lastname.getText();
password = signuppassword.getText();
uname = username.getText();
mail = emailid.getText();
mob = mobile.getText();
if (fname.equals("")) {
JOptionPane.showMessageDialog(this, "Please enter first name");
return false;
}
if (lname.equals("")) {
JOptionPane.showMessageDialog(this, "Please enter last name");
return false;
}
if (uname.equals("")) {
JOptionPane.showMessageDialog(this, "Please enter user name");
return false;
}
if (password.equals("")) {
JOptionPane.showMessageDialog(this, "Please enter password");
return false;
}
if (mail.equals("")) {
JOptionPane.showMessageDialog(this, "Please enter email");
return false;
}
if (mob.equals("")) {
JOptionPane.showMessageDialog(this, "Please enter mobile number");
return false;
}
if (password.length()<8) {
JOptionPane.showMessageDialog(this, "Length of password should be greater than 8");
return false;
}
if (mob.length()!=10) {
JOptionPane.showMessageDialog(this, "Please enter valid mobile number");
return false;
}
return true;
}
public void checkPass() {
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(signup.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(signup.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(signup.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(signup.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new signup().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField emailid;
private javax.swing.JTextField firstname;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JTextField lastname;
private javax.swing.JTextField mobile;
private javax.swing.JButton signupbutton;
private javax.swing.JPasswordField signuppassword;
private javax.swing.JTextField username;
// End of variables declaration//GEN-END:variables
}