<%@ 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 passwd= request.getParameter("password");
   String sql="";
   String delsql="";
   
   ResultSet rs=null;
   String str="";
   
   try{
	 
	   Class.forName("oracle.jdbc.driver.OracleDriver");
	   Connection  conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20162496","980216");
	   sql="select id from MEMBER_TABLE where id=?";
	   PreparedStatement pstmt=conn.prepareStatement(sql);
	   pstmt.setString(1, id);
	   rs=pstmt.executeQuery();
	  	    
		if(rs.next()){
			String rid=rs.getString("id");
			 
			if(id.equals(rid)){
				delsql="delete from MEMBER_TABLE where id=?"; 
				pstmt=conn.prepareStatement(delsql);
				pstmt.setString(1,id);
				pstmt.executeUpdate();
				
			}
		}
		rs.close();
		pstmt.close();
		conn.close();  
	 	 
 	 str= "회원 탈퇴되었습니다. 이욯해 주셔서 감사합니다.";
 	 session.invalidate();
 	}catch(Exception e){ 
 		e.printStackTrace();
 		str="다시 시도해 주세요.";
	
 	}
 %>
<html>
<head>
<title>회원 탈퇴</title>
</head>
<body>
  <%=str %>  <p>
  
 <A href="http://localhost:8080/Project/main.jsp">메인으로 이동하기! </A>
 <meta http-equiv="Refresh" content="10" url="login.jsp">
</body>
</html>