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

<% request.setCharacterEncoding("utf-8");%>

<%
String id=request.getParameter("id");
String pw=request.getParameter("pw");
String name=request.getParameter("name");
String bYear=request.getParameter("bYear");
String bMonth=request.getParameter("bMonth");
String bDay=request.getParameter("bDay");
String email=request.getParameter("email");
String phone=request.getParameter("phone");

String str="";

ResultSet rs=null;

String sql=null;

try{
	Class.forName("oracle.jdbc.driver.OracleDriver");
	Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20182264","981218");
	sql="select * from member_2 where id=? ";
	PreparedStatement pstmt=conn.prepareStatement(sql);
	
	pstmt.setString(1,id);
	
	rs=pstmt.executeQuery();
	
	if(rs.next()){
		String dbPass=rs.getString("pw");
		if(pw.equals(dbPass)){
			pstmt=conn.prepareStatement("update member_2 set pw=?,name=?,bYear=?,bMonth=?,bDay=?,email=?,phone=? where id=?");
			
			pstmt.setString(1,pw);
			pstmt.setString(2,name);
			pstmt.setString(3,bYear);
			pstmt.setString(4,bMonth);
			pstmt.setString(5,bDay);
			pstmt.setString(6,email);
			pstmt.setString(7,phone);
			pstmt.setString(8,id);
			
			pstmt.executeUpdate();
			str="정보수정 성공";
		}
	}else{
		str="비밀번호틀림";
	}
}catch(Exception e){
	e.printStackTrace();
	
}finally{
}

%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>내정보 수정하기</title>
</head>
<body>
<h2>내정보 수정하기</h2>
<%=str %><br>
<a href="http://localhost:8080/FinalTest2/Main.jsp">main 화면으로 돌아가기</a>
</body>
</html>

