<%@ 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 password = request.getParameter("password");
    String repassword = request.getParameter("repassword");
    String name = request.getParameter("name");
    String year = request.getParameter("year");
    String month = request.getParameter("month");
    String day = request.getParameter("day");
    String zipcode = request.getParameter("zipcode");
    String address = request.getParameter("address");
    String email = request.getParameter("email");
    String job = request.getParameter("job");
    
    String birth = year + "-" + month + "-" + day;
    String zip = zipcode;
    String addadd = address;
    String addemail = email;

    
    try{
	
    	Class.forName("oracle.jdbc.driver.OracleDriver");
    	Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20162513","970709");
    	PreparedStatement pstmt = conn.prepareStatement(" select * from member_20190514 where id = ?");
		pstmt.setString(1, id);
		ResultSet rs=pstmt.executeQuery();
		
	
	if(rs.next()) {
		String dbPass=rs.getString("password");
		if(password.equals(dbPass)){
			pstmt=conn.prepareStatement("update member_20190514 set PASSWORD=?, NAME=?, YYYYMMDD=?, ZIPCODE=?, ADDRESS=?, EMAIL=?, JOB=? where id=?");
			
			pstmt.setString(8,id);
			pstmt.setString(1,repassword);
			pstmt.setString(2,name);
			pstmt.setString(3,birth);
			pstmt.setString(4,zipcode);
			pstmt.setString(5,addadd);
			pstmt.setString(6,addemail);
			pstmt.setString(7,job);

			
			
			pstmt.executeUpdate();%>
			<script>
alert("정보수정완료");
location.href="main.jsp"</script>
<%
			
		} else {
			%>
			<script>
			alert("비밀번호가 틀렸습니다.");
			location.href="editForm.jsp"</script>
			<%
		}
	}else{

	}
	
}catch(Exception e){

	e.printStackTrace();
}finally{
	
}
%>
