<%@ 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 pw=request.getParameter("pw");
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","20182264","981218");
	sql="select id from member_2 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 member_2 where id=?";
			pstmt=conn.prepareStatement(delsql);
			pstmt.setString(1,id);
			pstmt.executeUpdate();
		}
	}
	rs.close();
	pstmt.close();
	conn.close();
	
	str="회원탈퇴 성공";
}catch(Exception e){
	e.printStackTrace();
	str="회원탈퇴 실패";
}
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>회원탈퇴</title>
</head>
<body>
<%=str %><br>
<a href="http://localhost:8080/FinalTest2/LoginForm.jsp">로그인하러 가기</a><br>
<a href="http://localhost:8080/FinalTest2/List.jsp">리스트보기</a>

</body>
</html>