-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjoining.jsp
124 lines (108 loc) · 2.63 KB
/
joining.jsp
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
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page language = "java" import ="java.text.*, java.sql.*,java.util.ArrayList"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>join</title>
</head>
<body>
<%
String serverIP = "localhost";
String strSID = "orcl";
String portNum = "1521";
String user = "university";
String pass = "comp322";
String url = "jdbc:oracle:thin:@"+serverIP+":"+portNum+":"+strSID;
String idcheck = "false";
Connection conn = null; // Connection object
Statement stmt = null; // Statement object
ResultSet rs;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection(url,user,pass);
String sql ="";
String id = (String)session.getAttribute("id");
String name = request.getParameter("name");
String pw = request.getParameter("pw");
String pw2 = request.getParameter("pw2");
String birth = request.getParameter("birth");
String address = request.getParameter("address");
String sex = request.getParameter("sex");
String job = request.getParameter("job");
String phone = request.getParameter("phone");
String key = (String)session.getAttribute("key");
String error= "";
String haserror = "true";
if(pw.equals(""))
{
error +="please check your password<br>";
}
if(pw2.equals(""))
{
error += "please check your password2<br>";
}
if(name.equals(""))
{
error += "please check your name<br>";
}
if(birth.equals(""))
{
error += "please check your birthday<br>";
}
if(address.equals(""))
{
error += "please check your address<br>";
}
if(job.equals(""))
{
error += "please check your job<br>";
}
if(phone.equals(""))
{
error += "please check your phone number<br>";
}
if(!pw.equals(pw2))
{
error += "please check your password<br>";
}
else if(key.equals("true"))
{
if(sex.equals("m"))
{
sex = "true";
}
else{
sex = "false";
}
try {
conn.setAutoCommit(false);
stmt = conn.createStatement();
sql = "INSERT INTO ACCOUNT VALUES('"+id+"','"+name+"','"+sex
+"',TO_DATE('"+birth+"','mm-dd-yyyy'),'"+address+"','"+job+"','"+phone
+"','"+pw+"','true')";
System.out.println(sql);
int res = stmt.executeUpdate(sql);
haserror = "false";
conn.commit();
}catch(SQLException ex2) {
System.err.println("sql error = "+ex2.getMessage());
System.exit(1);
}
}
else{
error += "please check id duplication<br>";
haserror = "true";
}
if(haserror.equals("true"))
{
session.setAttribute("error", error);
response.sendRedirect("failjoin.jsp");
}
else
{
response.sendRedirect("welecome.jsp");
}
%>
</body>
</html>