<%@ 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","20162487","970901");
		PreparedStatement pstmt=conn.prepareStatement("select * from member");
	    ResultSet rs= pstmt.executeQuery();
	    
	    while(rs.next()){
	    	if (id.equals(rs.getString("id")) && pwd.equals(rs.getString( "password"))) {
	          	session.setAttribute("id",id);
	    		session.setAttribute("pwd",pwd);
	    		response.sendRedirect("main.jsp");
	    	} else {
	    		//response.sendRedirect("loginForm.jsp");
	    		str="회원인지 다시 확인해 주세요.";
	    	}}}catch(Exception e){
	    		e.printStackTrace();
	    	}
%>
<html align="center">
<head>
<title>로그인</title>
<link href="css01.css" rel="stylesheet" type="text/css">
<style>
body
{background-color:#CDF3F3;}
</style>
</head>
<body>
<div id="parent">
<div id="loginPro">
<p style="color:#4AABFC"><%=str %></p>
<style type="text/css"> 
a { text-decoration:none } 
</style>  
<A href="inputForm.jsp"><font size="5">회원가입</font></A>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<A href="loginForm.jsp"><font size="5">돌아가기</font></A>
</div>
</div>
</body>
</html>