<%@ 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" %>
	

<%
	String id = request.getParameter("id");
	String passwd = request.getParameter("pwd");

	Class.forName("oracle.jdbc.driver.OracleDriver");
	Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl", "20172310", "980301");
	String sql = "select * from O_MEMBER_2";
	PreparedStatement pstmt = conn.prepareStatement(sql);
	ResultSet rs = pstmt.executeQuery();
	
	String id2="";
	String pwd1="";
	
	session.setAttribute("id", id);
	session.setAttribute("passwd", passwd);
	
	while(rs.next()){
		id2 = rs.getString("id");
		pwd1 = rs.getString("password");
		if(id.equals(id2) && pwd1.equals(pwd1)) {
			break;
		}
	}
			
	if(id.equals(id2)&&passwd.equals(pwd1)){
		response.sendRedirect("main.jsp");
	}else{%>
	<script>
		alert("아이디 또는 비밀번호를 다시 확인하세요.");
		history.go(-1);
	</script>
	<%}%>	
	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

</body>
</html>