<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
    <%@ 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" %>
    
    <%
    String uid=request.getParameter("id");
    String upass=request.getParameter("pass");
    
    
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<%
    try{
		Class.forName("oracle.jdbc.driver.OracleDriver");
		Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20182224","990804");
		PreparedStatement pt=conn.prepareStatement("select * from R_MEMBER");
		ResultSet rs=pt.executeQuery();
		while(rs.next()){
			if(uid.equals(rs.getString("USERID")) && upass.equals(rs.getString("USERPASS"))){
				session.setAttribute("id",uid);
				session.setAttribute("pass",upass);
				session.setAttribute("name",rs.getString("USERNAME"));
				response.sendRedirect("../main.jsp");
			}else{%> <script>alert("아이디와 비밀번호를 확인해주세요.");
			location.href="../form/loginf.jsp"</script><% 
			}}}catch(Exception e){
    	e.printStackTrace();
    	%> <script>alert("로그인에 실패하셨습니다.");
    	location.href="../form/loginf.jsp";</script><%
    	
    	
    	}
    %>
    
</body>
</html>