<%@ 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"%>
<%@ page session="true" %>

<% request.setCharacterEncoding("EUC-KR"); %>
<%
	if(session.getAttribute("login").equals("0") || session.getAttribute("id").equals("admin")){
		%> <script>alert('잘못된 접근입니다.'); location.href="http://localhost:8080/Park20162515/Main.jsp"</script><%
	}
	String id = (String)session.getAttribute("id");
	String pw = request.getParameter("pw");
	
	String str="";
	
	try
	{
		Class.forName("oracle.jdbc.driver.OracleDriver");
		Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20162515","970623");
		PreparedStatement pstmt = conn.prepareStatement("select * from member_1 where id = ?");
		pstmt.setString(1, id);
		ResultSet rs = pstmt.executeQuery();
		
		if(rs.next()){
			String dbPass = rs.getString("pw");
			
			if(pw.equals(dbPass)){
				pstmt = conn.prepareStatement("delete member_1 where id=?");
				pstmt.setString(1,id);
				pstmt.executeUpdate();
				pstmt.close();
				conn.close();
				session.invalidate();
				%> <script>alert('지금까지 이용해 주셔서 감사합니다.'); location.href="http://localhost:8080/Park20162515/Main.jsp"</script><%
			}else{
				pstmt.close();
				conn.close();
				%> <script>alert('비밀번호가 틀렸습니다.\n메인화면으로 돌아갑니다'); location.href="http://localhost:8080/Park20162515/Main.jsp"</script><%
			}
		}
	}catch(Exception e){
		e.printStackTrace();
	}
%>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>

</body>
</html>