<%@ 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 id = request.getParameter("id");
    String pwd = request.getParameter("pwd");
    
    String str="";
    
    try{
    	Class.forName("oracle.jdbc.driver.OracleDriver");
      	Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20162505","970401");
      	PreparedStatement pstmt=conn.prepareStatement("select * from member_2");
    	ResultSet rs=pstmt.executeQuery();
    	
    	while(rs.next()){
    		if (id.equals(rs.getString("id")) && pwd.equals(rs.getString("pw"))) {
    			
    			session.setAttribute("id",id);
    			session.setAttribute("pw",pwd);
    			response.sendRedirect("main2.jsp");
    			
    		}
    		else { 
    			str="로그인에 실패했습니다.";
    		}}}
    		catch(Exception e){
    			e.printStackTrace();
    		}
    	%>
<!DOCTYPE html>
<html>
<head>
<style>
body
{
    background-color: #5CD1E5;
}
</style>
<style type="text/css"> 
a { text-decoration:none } 
</style> 
<meta charset="UTF-8">
<title>로그인</title>
</head>
<body>
<table border="10" align="center" bordercolor=#008299>
<tr>
<th width = "800" align="center" colspan="3"  bgcolor=#B2EBF4><H1>이런!</H1></th>
</tr>
<tr>
<td width = "600" rowspan="3" align="center"  bgcolor=#B2EBF4>
<%=str %> <p>
다시 시도해주세요.
</tr>
<tr>
<td algin="center" bgcolor=#B2EBF4 >
<button type="button" class="btn btn-default" onclick="location.href='main.jsp'">메인화면</button></td>
</tr>
</table>


</body>
</html>