<%@ 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 password= 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","20162487","970901");
	   sql="select password from member where id=?";
	   PreparedStatement pstmt=conn.prepareStatement(sql);
	   pstmt.setString(1, id);
	   rs=pstmt.executeQuery();
	  	    
		if(rs.next()){
			String rid=rs.getString("password");
			 
			if(password.equals(rid)){
				delsql="delete from member where id=?";  // sql DELETE: DELETE FROM 테이블명 WHERE 삭제조건
				pstmt=conn.prepareStatement(delsql);
				pstmt.setString(1,id);
				pstmt.executeUpdate();
				
			}
		}
		rs.close();
		pstmt.close();
		conn.close();  
	 	 
 	 str= "정상적으로 탈퇴되었습니다.";
 	}catch(Exception e){ 
 		e.printStackTrace();
 		str="회원탈퇴를 다시 진행해주세요.";
	
 	}
 %>
<html align="center">
<head>
<title>회원탈퇴</title>
<link href="css01.css" rel="stylesheet" type="text/css">
<style>
body
{background-color:#CDF3F3;
</style>
</head>
<body>
<div id="parent">
<div id="main">
  <p style="color:#0099ff"><%=str %></p>
<style type="text/css"> 
a { text-decoration:none } 
</style>  
 <A href="loginForm.jsp"><font size="5">확인</font></A>
</div>
</div>  
</body>
</html>