<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.sql.Connection"%>
<%@ page import="java.sql.DriverManager"%>
<%@ page import="java.sql.PreparedStatement"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page session="true" %>

<% request.setCharacterEncoding("EUC-KR"); %>
<%
	String id = (String)session.getAttribute("id");
	String pw = request.getParameter("pw");
	String pwc = request.getParameter("pwc");
	String name = request.getParameter("name");
	String brithday = request.getParameter("brithday");
	String zipcode = request.getParameter("zipcode");
	String zip = request.getParameter("zip");
	String email = request.getParameter("email");
	String job = request.getParameter("job");
	
	try
	{
		Class.forName("oracle.jdbc.driver.OracleDriver");
		Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20162515","970623");
		PreparedStatement pstmt = conn.prepareStatement("select * from member_1 where id = ?");
		pstmt.setString(1, id);
		ResultSet rs = pstmt.executeQuery();
		
		if(rs.next()){
			if(pwc.equals(rs.getString("pw"))){
				pstmt = conn.prepareStatement("update member_1 set pw=?, name=?, birthday=? ,zipcode=? ,zip=? ,email=? ,job=? where id=?");
				pstmt.setString(8,id);
				pstmt.setString(1,pw);
				pstmt.setString(2,name);
				pstmt.setString(3,brithday);
				pstmt.setString(4,zipcode);
				pstmt.setString(5,zip);
				pstmt.setString(6,email);
				pstmt.setString(7,job);
				pstmt.executeUpdate();
				%> <script>alert('회원님의 정보가 수정되었습니다!'); location.href="http://localhost:8080/Park20162515/Main.jsp"</script><%
			}else{
				%> <script>alert('비밀번호가 틀렸습니다.'); location.href="http://localhost:8080/Park20162515/Edit.jsp"</script><%
			}
		}
	}catch(Exception e){
		e.printStackTrace();
	}
%>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>

</body>
</html>