<%@ 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" %>
    
    <%
    String id=request.getParameter("id");
    String pass=request.getParameter("pass");
    String yn=request.getParameter("yn");
    String str="Y";
    %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%

if(yn.equals(str)){
try{
	Class.forName("oracle.jdbc.driver.OracleDriver");
	Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20182224","990804");
	PreparedStatement pt=conn.prepareStatement("select * from R_MEMBER");
	ResultSet rs=pt.executeQuery();
	while(rs.next()){
		if(id.equals(rs.getString("USERID")) && pass.equals(rs.getString("USERPASS"))){
			pt=conn.prepareStatement("DELETE R_MEMBER WHERE USERID='"+id+"' AND USERPASS='"+pass+"'");
			rs=pt.executeQuery();
			session.invalidate();	
			%> <script>alert("회원탈퇴가 성공적으로 이루어졌습니다. 홈페이지를 이용해주셔서 감사합니다.");
			location.href="../main.jsp";
			</script><%
		}else{
			%> <script>alert("회원탈퇴에 실패하셨습니다.");
			location.href="../form/deletef.jsp";</script><%
		}}}catch(Exception e){
	e.printStackTrace();
	%> <script>alert("회원탈퇴에 실패하셨습니다.");
	location.href="../form/deletef.jsp";</script><%
	
	
	}

}else{
	%> <script>alert("회원탈퇴를 하려면 박스의 글자가 Y가 되어야 합니다.");
	location.href="../form/deletef.jsp";</script><%
	
}
%>


</body>
</html>