<%@ 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");    
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","20182234","990802");
	   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 name=? where id=? and password=? ");
		                                    //UPDATE 테이블명 SET 컬럼명=새로운값 WHERE 업데이트조건 
		 pstmt.setString(1, name);
		pstmt.setString(2, id);
		pstmt.setString(3, password);
		
		  
		  pstmt.executeUpdate();
		  response.sendRedirect("editPro2.jsp");
	 }else{
	 		str="정보수정실패";
	 }}

}catch(Exception e){
e.printStackTrace();
}finally{
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
body{
		background-color:black;
	}
	</style>
</head>
<body>
<script>
alert("Edit Failed !");
location.href="editForm.jsp";
</script>
</body>
</html>

