<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<% request.setCharacterEncoding("utf-8");%>
<% 
   String id = request.getParameter("id");
   String password= request.getParameter("password");
   
   try{
	   Class.forName("oracle.jdbc.driver.OracleDriver");
	   Connection  conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20152488","960504");
	   PreparedStatement pstmt=conn.prepareStatement("select * from membership");
	   ResultSet rs=pstmt.executeQuery();
	   
	   while(rs.next()){
		   if(id.equals(rs.getString("id")) && password.equals(rs.getString("password")) && !id.equals("admin")){
			   if(id.equals(session.getAttribute("id")) || session.getAttribute("id").equals("admin")) {
			   	pstmt=conn.prepareStatement("delete from membership where id=?");
			   	pstmt.setString(1,id);
			   	pstmt.executeUpdate();
			   	%><script>alert("회원탈퇴성공");
				location.href="main.jsp";</script> <%
			   	if(!session.getAttribute("id").equals("admin")) {
					session.invalidate();
				}
			   }
			}
		}
	   %><script>alert("아이디, 패스워드 확인바람");
		location.href="updateForm.jsp";</script> <%
 	}catch(Exception e){ 
 		e.printStackTrace();	
 	}
 %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>

</body>
</html>