<%@ 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;
String str="";
try{
	   Class.forName("oracle.jdbc.driver.OracleDriver");
	   Connection  conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20162487","970901");
	   sql="select * from member 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 set password=?,  name=? where id=?");
		                                    //UPDATE 테이블명 SET 컬럼명=새로운값 WHERE 업데이트조건 
		  pstmt.setString(1,password);
		  pstmt.setString(2,name);
		  pstmt.setString(3,id);
		  
		  pstmt.executeUpdate();
		  str="정보를 수정하였습니다.";
	 }else{
	 str="비밀번호를 다시 입력해주세요";
	 }}

}catch(Exception e){
e.printStackTrace();
}finally{
}
%>
<html align="center">
<head>
<title>정보수정</title>
<link href="css01.css" rel="stylesheet" type="text/css">
<style>
body
{background-color:#CDF3F3;}
</style>
</head>
<body>
<div id="parent">
<div id="inputPro">
<p style="color:#4AABFC"><%=str %></p>
<p>
<style type="text/css"> 
a { text-decoration:none } 
</style>
 <A href="editForm.jsp"><font size="5">돌아가기</font></A>&nbsp;&nbsp;&nbsp;
 <A href="list.jsp"><font size="5">회원정보보기</font></A>
</div>
</div>  
</body>
</html>
