<%@ 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("utf-8"); %>
    
    <%
    String id=(String)session.getAttribute("id");
    String passwd = request.getParameter("password");
    String sql="";
    String delsql="";
    ResultSet rs=null;
    
    String str="";
    
    try {
    
    Class.forName("oracle.jdbc.driver.OracleDriver");  //oracle드라이버 로드
    Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20162511","971204");
    sql="select pass from member where id=?";
    PreparedStatement pstmt=conn.prepareStatement(sql);
    pstmt.setString(1, id);
    rs = pstmt.executeQuery();
    
    if(rs.next()){
    String dbPass=rs.getString("pass");
    if(passwd.equals(dbPass)){
    	delsql="delete from member where id=?";
    	pstmt=conn.prepareStatement(delsql);
    	pstmt.setString(1,id);
    	pstmt.executeUpdate();
    }
    }
    rs.close();
    pstmt.close();
    conn.close();
    session.invalidate();
    str="회원삭제";
    }catch(Exception e){
    	e.printStackTrace();
    	str="회원삭제 실패";
    }
    %>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body bgcolor="#aee19b"style="text-align:center;">
<jsp:include page="Head.jsp" /><br>
<%=str %>

</body>
</html>