<%@ 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","20182233","991227");
	   sql="select id from o_member 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 o_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= "회원 정보를 삭제했습니다.<br>이용해주셔서 감사합니다.";
 	}catch(Exception e){ 
 		e.printStackTrace();
 		str="회원 정보 삭제를 실패했습니다.<br>다시 확인해주세요";
	
 	}
 %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
<html>

<head>
<title>회원 탈퇴</title>
</head>

<body>

<form method="post">

<table width = "400" align = "center" style="border-collapse:collapse;">

<tr>
<td>
<div style="font-size:25px; text-align:center; color:#346E73; padding:5px;">
<%=str %>
</div>
</td>
</tr>

<tr>
<td>
<br><div style="font-size:15px; text-align:center; padding:5px;">
<A href="http://localhost:8080/PSY/Fin/list.jsp">클릭시 회원 정보 목록 화면으로 이동합니다.</A>
</div>
</td>
</tr>

</table>

</form>
</body>
</html>