<%@ 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 password=request.getParameter("password");
String name=request.getParameter("name");
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","20182263","980629");
	   sql="select * from member_1 where id=? ";
	   PreparedStatement pstmt=conn.prepareStatement(sql);
	   pstmt.setString(1, id);
	   
	   rs=pstmt.executeQuery(); //결과 가져옴
	  
	  if(rs.next()){
	  String dbPass=rs.getString("password");
	  if(password.equals(dbPass)){
	  	  pstmt=conn.prepareStatement("update member_1 set password=?,  name=? where id=?");
		  pstmt.setString(1,password);
		  pstmt.setString(2,name);
		  pstmt.setString(3,id);
		  
		  pstmt.executeUpdate();%>
		  <div align="center">정보 수정 성공!</div>
		  <div align="center"><p><a href="http://localhost:8080/Exam/MainPage2.jsp">홈으로</a></div>
		  <%
	 }else{ %>
	 <div align="center">비밀번호를 다시 확인해주세요.</div>
	 <% }}

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