<%@ 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 = (String)session.getAttribute("id");
String password= request.getParameter("password");

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","20161505","961120");
	   sql="select * from log_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)){  //if(password.equals(dbPass)){   //if(rs.next()){ 

		  	  pstmt=conn.prepareStatement("delete from log_member where id=?");
			                                    //UPDATE 테이블명 SET 컬럼명=새로운값 WHERE 업데이트조건 
			  pstmt.setString(1,id);
			  
			  pstmt.executeUpdate(); 
			  
				session.invalidate();//로그아웃되며 세션값도 삭제
			  %>
			<script>
				alert("회원정보가 삭제되었습니다.");
				location.href="../../Home.jsp";
			</script>
		 <%		
	  	}else{
			  %>
			<script>
				alert("비밀번호가 일치하지 않습니다.");
				location.href="deleteForm.jsp";
			</script>
		 <%	
		 }

	}

}catch(Exception e){
	out.print("오류");
	e.printStackTrace();
}finally{
}
%>