<%@ 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","20182237","990218");
		PreparedStatement pstmt=conn.prepareStatement("select * from O_MEMBER");
		   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("main.jsp");
	  
	    break;
	    	}
	    	else{
	    		 str="잘못 입력하셨습니다.";   
	    	}
	    
	    }
	    sql="delete from O_MEMBER 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="brown">
<title>Insert title here</title>
</head>
<body bgcolor="yellow">
<%=str %><br>
 <A href="http://localhost:8080/a3/main.jsp" >홈으로</A>
</body>
</html>