<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
                <%@ 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("EUC-KR"); %>
    
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body style = " text-align : center; ">
<h2>회 원 탈 퇴</h2>
<hr>

<%
    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","20162513","970709");
    	sql="select id from member_20190514 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_20190514 where id=?";
    			pstmt=conn.prepareStatement(delsql);
    			pstmt.setString(1,id);
    			pstmt.executeUpdate();
    			out.println("삭제 성공");
    		}
    	}
    	
    	
    }catch(Exception e){
    	e.printStackTrace();
    } finally{
    	
    }
    %>
    <%
session.invalidate();%>

<A href="http://localhost:8080/woo/main.jsp" >메인페이지로</p>
</body>
</html>