-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSignUpOk.jsp
More file actions
65 lines (51 loc) · 1.82 KB
/
SignUpOk.jsp
File metadata and controls
65 lines (51 loc) · 1.82 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
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<html>
<body>
<%
request.setCharacterEncoding("UTF-8");
String id = request.getParameter("id");
String password = request.getParameter("pw");
String name = request.getParameter("name");
String hp1 = request.getParameter("hp1");
String hp2 = request.getParameter("hp2");
String hp3 = request.getParameter("hp3");
String hp = hp1 + hp2 + hp3;
String email1 = request.getParameter("email1");
String email2 = request.getParameter("email2");
String email = email1 + "@"+ email2;
String birth = request.getParameter("birth");
String sex = request.getParameter("sex");
try {
String DB_URL="jdbc:mysql://localhost:3306/internetproject";
String DB_ID="multi";
String DB_PASSWORD="abcd";
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection(DB_URL, DB_ID, DB_PASSWORD);
String jsql = "INSERT INTO User (userId, password, name, phone, email, birth, gender) VALUES (?,?,?,?,?,?,?)";
PreparedStatement pstmt = con.prepareStatement(jsql);
pstmt.setString(1,id);
pstmt.setString(2,password);
pstmt.setString(3,name);
pstmt.setString(4,hp);
pstmt.setString(5,email);
pstmt.setString(6,birth);
pstmt.setString(7,sex);
int result = pstmt.executeUpdate();
if(result == 1){ // 성공 %>
<script>
alert("회원가입에 성공하였습니다.");
window.location.href = "<%= request.getContextPath() %>/Login.jsp";
</script>
<% } else{ // 실패 %>
<script>
alert("회원가입에 실패하였습니다.");
window.location.href = "<%= request.getContextPath() %>/SignUp.jsp";
</script>
<% }
} catch(Exception e) {
out.println(e);
}
%>
</body>
</html>