<%@ 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.PreparedStatement"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.sql.DriverManager" %>

<% request.setCharacterEncoding("utf-8"); %>

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

	String str="";
	String authority = "";
	String dbauthority = "";//권한여부
	ResultSet rs=null;

	String sql=null;

try{ //id값과 비교해서 권한값 가져오기
	   Class.forName("oracle.jdbc.driver.OracleDriver");
	   Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20161505","961120");
	   sql="select authority from log_member where id=? ";
	   PreparedStatement pstmt=conn.prepareStatement(sql);
	   pstmt.setString(1, id);
	   
	   rs=pstmt.executeQuery(); //결과 가져옴
	  
	  if(rs.next()){
		authority=rs.getString("authority");
		}
	}catch(Exception e){
e.printStackTrace();
out.print("오류");
}finally{
}
	
//////////////////////////////////////////////////////////////////////////////////////////////////////
	try{
		Class.forName("oracle.jdbc.driver.OracleDriver");
		Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20161505","961120");
		PreparedStatement pstmt = conn.prepareStatement("select * from log_member");
		
		
		rs=pstmt.executeQuery();
		
		while(rs.next()){
			if(id.equals(rs.getString("id")) && password.equals(rs.getString("password"))){

				session.setAttribute("id",id);
				session.setAttribute("password",password);
				session.setAttribute("authority",authority);
				response.sendRedirect("../../Home.jsp");
			}else{%>
				<script>
					alert("로그인에 실패하였습니다. 아이디/비밀번호를 다시 확인해주세요.")
					location.href="IdentifyLoginForm.jsp";
				</script>
			<%}}} catch(Exception e) {
		e.printStackTrace();
		out.print("오류");
			
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
%>
<!DOCTYPE html>
<html>
<head>
<title>로그인</title>
</head>
<body>
	<p>
</body>
</html>


