<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.sql.DriverManager" %>
<%@ page import = "java.sql.Connection" %>
<%@ page import = "java.sql.PreparedStatement" %>
<%@ page import = "java.sql.ResultSet" %>
<%@ page session="true" %>

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

<!DOCTYPE html>
<html>
<head>
			<link href='../../css/join_style.css.css' rel='stylesheet' style='text/css'/>
  <script>
       function goLogoutPro(){
           location.href="LogoutPro.jsp";
           }
       function goLoginForm(){
           location.href="../view/LoginForm.jsp"; 
           }
       function goUserInfoForm(){
           location.href="../view/UserInfoForm.jsp"; 
           }
  </script>
</head>

<title>레코드추가</title>

<body>
<%
	String id = request.getParameter("id");
	String pwd = request.getParameter("pwd");
	String str = "";
	int i = 0; //두가지의 경우의 수를 위한 int 형 선언



try{
	   Class.forName("oracle.jdbc.driver.OracleDriver");
	   Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20150001","960323");
	   PreparedStatement pstmt=conn.prepareStatement("select * from O_MEMBER2");
	   ResultSet rs=pstmt.executeQuery();
	   
	   while(rs.next()){
		   if (id.equals(rs.getString("id")) && pwd.equals(rs.getString("password"))) {
			   session.setAttribute("id",id);
			   session.setAttribute("password",pwd);
			   str="로그인에 성공하셨습니다.(메인화면입니다.)";
			   i = 1;// true 에 대한 정수형 선언
			   break;
 
	   }  else{
			   //response.sendRedirect("loginFrom.jsp");
			   str="회원인지 다시 확인해주세요";
		    }}}catch(Exception e){
			   e.printStackTrace();
			   str="오류가 발생했습니다.";
			   
		   }%>
		 
			
			    
			    
<p style="text-align:center;">
<a style="font-size:20px;">
<%=str %>
<br>

  <%
     if(i == 1){ //i==1 일시 로그아웃, 내정보 버튼 출력
   %>
   
		<input type = "button" value = "로그아웃" onclick = "goLogoutPro()"  class= "btn">
		<input type = "button" value = "내 정보" onclick = "goUserInfoForm()" class= "btn">
		
    <%}else{//아닐시 뒤로 출력
    	
    %>
		<input type = "button" value = "뒤로" onclick = "goLoginForm()" class="btn">
   <%}%>
       </a>
     </p>
  </body>
</html>