<%@ 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","20162505","970401");
	   sql="select pw from member_2 where id=?";
	   PreparedStatement pstmt=conn.prepareStatement(sql);
	   pstmt.setString(1, id);
	   rs=pstmt.executeQuery();
	  	    
		if(rs.next()){
			String rid=rs.getString("pw");
			if(pw.equals(rid)){
				delsql="delete from member_2 where id=?";  // sql DELETE: DELETE FROM 테이블명 WHERE 삭제조건
				pstmt=conn.prepareStatement(delsql);
				pstmt.setString(1,id);
				pstmt.executeUpdate();
				response.sendRedirect("main.jsp");
			}
		}
		rs.close();
		pstmt.close();
		conn.close();  
 	}catch(Exception e){ 
 		e.printStackTrace();
 		str="잘못 입력하셨습니다.";
	
 	}
 %>
<html>
<head>
<style>
body
{
    background-color: #5CD1E5;
}
</style>
<style type="text/css"> 
a { text-decoration:none } 
</style> 
<title>이승기-삭제</title>
</head>
<body>
<table border="10" align="center" bordercolor=#008299>
<tr>
<th width = "800" align="center" colspan="3" bgcolor=#B2EBF4 height="70"><H1>이런!</H1></th>
</tr>
<tr>
<td width = "600" height="50" rowspan="3" align="center" bgcolor=#B2EBF4>
<%=str %> <p>
입력하신 정보가 일치하지 않습니다.
</tr>
<tr>
<td algin="center" bgcolor=#B2EBF4>
<a href="delete.jsp">이전 화면으로</a></td>
</tr>
</table>


</body>
</html>
