<%@ 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 authority = (String)session.getAttribute("authority"); //세션에서 권한값 가져오기
%>

 <html>
 <link rel="stylesheet" href="visual.css">
 <head>
 <title>회원목록</title>
 </head>
 <body>
 
 <!-- ---------------------------------------------------------------------------------------------------------- -->
 <%if(authority.equals("0")){ %>
<table border=1>
<tr>
<p><td colspan = "3" span style="color:white; text-align:center; font-size:55px">회원목록</td></p>
</tr>
<tr>
<th style="width:230px;">아이디</th>
<th style="width:230px;">이름</th>
</tr>
<%
ResultSet rs=null;

try{
	 
	Class.forName("oracle.jdbc.driver.OracleDriver");
	Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20161505","961120");
	PreparedStatement pstmt = conn.prepareStatement("select * from log_member");
		rs=pstmt.executeQuery();
		
		while(rs.next()){
			String id=rs.getString("id");
			String name=rs.getString("name");
			 		
			%>
			<tr>
			<td style="padding:5px">   <%= id %></td>
			<td style="padding:5px">   <%= name %></td>
			 			
			</tr>
						
		<% }
}catch(Exception e){ 
		e.printStackTrace();
}
%>
</table>
<%} else{ %>
 <!-- ---------관리자모드----------------------------------------------------------------------------------------- -->

 <table border=1>
<tr>
<p><td colspan = "7" span style="color:white; text-align:center; font-size:55px">회원목록</td></p>
</tr>
<tr>
<p><td colspan = "7" span style="color:white; text-align:center; font-size:55px">
	<a href="Admin/Authority/giveAuthorityForm.jsp"><input type="button" value="권한 부여" class="button"></a>
	<a href="Admin/deleteUser/deleteUserForm.jsp"><input type="button" value="회원 삭제" class="button"></a>
	
</td></p>
</tr>
<tr>
	<th style="width:100px;">권한</th>
	<th style="width:100px;">아이디</th>
	<th style="width:100px;">패스워드</th>
	<th style="width:100px;">이름</th>
	<th style="width:230px;">생년월일</th>
	<th style="width:230px;">이메일</th>
	<th style="width:130px;">휴대전화</th>
</tr>
<%
ResultSet rs=null;

try{
	 
	Class.forName("oracle.jdbc.driver.OracleDriver");
	Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20161505","961120");
	PreparedStatement pstmt = conn.prepareStatement("select * from log_member");
		rs=pstmt.executeQuery();
		
		while(rs.next()){
			String authority_check=rs.getString("authority");
			String express_authority="";
				if(authority_check.equals("1")){
					express_authority = "관리자";
				}else{
					express_authority = "일반사용자";
				}
			String id=rs.getString("id");
			String password=rs.getString("password");
			String name=rs.getString("name");
			String year=rs.getString("year");
			String month=rs.getString("month");
			String day=rs.getString("day");
			String email=rs.getString("email");
			String mail=rs.getString("mail");
			String phone_number=rs.getString("phone_number");
			 		
			%>
			<tr>
				<td style="padding:5px"><%= express_authority%></td>
				<td style="padding:5px"><%= id %></td>
				<td style="padding:5px"><%= password %></td>
				<td style="padding:5px"><%= name %></td>
				<td style="padding:5px"><%= year %>년 <%=month%>월 <%= day %>일</td>
				<td style="padding:5px"><%= email %>@<%= mail %></td>
				<td style="padding:5px"><%= phone_number %></td>
			</tr>
						
		<% }
}catch(Exception e){ 
		e.printStackTrace();
}
%>
</table>
 
 
<%} %>
<p style="text-align:center;">
<a href="Home.jsp"><input type="button" value="돌아가기"style="font-size:20px" class="button"></a>
</p>
  
</body>
</html>
