<%@ 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 passwd= request.getParameter("passwd");
   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","20162499","980202");
	   sql="select id,password from member where id=?";
	   PreparedStatement pstmt=conn.prepareStatement(sql);
	   pstmt.setString(1, id);
	 
	   rs=pstmt.executeQuery();
	  	    
		if(rs.next()){
			String rid=rs.getString("id");
			String rpw=rs.getString("password");
			 
			if(id.equals(rid)&&passwd.equals(rpw)){
				delsql="delete from member where id=?";  // sql DELETE: DELETE FROM 테이블명 WHERE 삭제조건
				pstmt=conn.prepareStatement(delsql);
				pstmt.setString(1,id);
				pstmt.executeUpdate();
				str= "회원탈퇴가 완료되었습니다.";
			}
			 else{

			  		str="회원탈퇴에 실패하였습니다.";
			 	 }
		}
		 else{

		  		str="존재하지않는 아이디입니다.";
		 	 }
		rs.close();
		pstmt.close();
		conn.close();  
	 	 
 	 
 	
 	}catch(Exception e){ 
 		e.printStackTrace();
 		
	
 	}
 %>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">

<title>로그인</title>
<link href="member.css" rel="stylesheet" type="text/css">

</head>
<body>
<div id="web">
 <div class="top">
 <div class="top_space">
 <div class="top_manu">
 <ul>
 <li>
 <a href="main.jsp"> 
 <span class="homeIcon"></span>메인페이지</a>
    </li>
    <li>
    <a href="logOut.jsp">
    <span class="loginIcon"></span>로그아웃</a>
    </li>
    <li>

 <a href="memberForm.jsp"><span class="signIcon"></span>회원가입</a>
 </li>
 </ul>
 </div></div><hr style="border:solid 0.7px #BDBDBD;"></div>

 
  <main id="main">
  <div class="main_bgspace1">
 <div class="main_bgsize1">
  <div class="main_deletebg">
  </div>
 </div>
 </div>
   <div class="main_tablespace">
 <div class="main_tablesize">
  <div class="main_table ">
<table border="0" width="500" height="180"  align="center" cellspacing="0"  class="text3">
<tr><td width="500" height="30"  align="center"><%=str%></tr></td>
<tr><td><br><input type="button" class="btn2" value="돌아가기" style="height:60px; width:500px;" onclick="location.href='deleteForm.jsp'"></td></tr>
<tr><td><br><input type="button" class="btn2" value="삭제확인하기 " style="height:60px; width:500px;" onclick="location.href='list.jsp'"></td></tr>
<tr><td><br><input type="button" class="btn2" value="메인페이지" style="height:60px; width:500px;" onclick="location.href='main.jsp'"></td></tr>
</table>
</form>
 </div>
 </div>
 </div>
 </main>
 <bottom id="bottom">
 </bottom>
 </div>
 

