<%@ 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" %>
<%@ page session="true" %>
    
    <%
    request.setCharacterEncoding("utf-8");
    String userid=request.getParameter("userid");
    String Password=request.getParameter("Password");
    String str="";
    String sql="";
   
    
    try{
    	Class.forName("oracle.jdbc.driver.OracleDriver");
		Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20182244","990621");
		PreparedStatement pstmt=conn.prepareStatement("select * from MEMBER_2A");
		   ResultSet rs= pstmt.executeQuery();
	    str="성공";
	    
	    
	    while(rs.next()){
	    	if(userid.equals(rs.getString("id")) && Password.equals(rs.getString("Password"))){
	    session.setAttribute("userid", userid);
	    session.setAttribute("Password",Password);
	    response.sendRedirect("delete.jsp");
	  
	    break;
	    	}
	    	else{
	    		 str="잘못 입력하셨습니다.";   
	    	}
	    
	    }
	    sql="delete from MEMBER_2A where id=?";  // sql DELETE: DELETE FROM 테이블명 WHERE 삭제조건
		pstmt=conn.prepareStatement(sql);
		pstmt.setString(1,userid);
		pstmt.executeUpdate();
	 	 
 	 
    }catch(Exception e){
    	e.printStackTrace();

    }
    %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>회원탈퇴</title>
</head>
<body bgcolor="lightblue">
<%=str %><br>
 <A href="http://localhost:8080/member12/abc/main.jsp">메인으로</A>
</body>
</html>