<%@ 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" %>
<% request.setCharacterEncoding("EUC-KR"); 
%>
<%

try
{
	String id = (String)request.getParameter("id");
	String pw = (String)request.getParameter("pw");
	Class.forName("oracle.jdbc.driver.OracleDriver");
	Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20162515","970623");
	PreparedStatement pstmt = conn.prepareStatement("select * from member_1 where id = ?");
	pstmt.setString(1, id);
	ResultSet rs = pstmt.executeQuery();

	if(rs.next()){
		String dbPass = rs.getString("pw");
		
		if(pw.equals(dbPass)){
			session.setAttribute("login","1");
			session.setAttribute("id",id);
			session.setAttribute("pw",pw);
			pstmt.close();
			conn.close();
			%> <script>alert('로그인되었습니다.'); location.href="http://localhost:8080/Park20162515/Main.jsp"</script><%
		}else{
			pstmt.close();
			conn.close();
			%><script>alert('비밀번호가 틀렸습니다.'); location.href="http://localhost:8080/Park20162515/Main.jsp"</script><%
		}
	}
}catch(Exception e){
	e.printStackTrace();
}
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<script>alert('아이디가 존재하지 않습니다.'); location.href="http://localhost:8080/Park20162515/Main.jsp"</script>
</body>
</html>