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

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>로그인</title>
</head>

<body>

<form method="post">

<table width = "370" align = "center" style="border-collapse:collapse;">

<tr>
<td>
<div style="font-size:25px; text-align:center; color:#346E73; padding:5px;">
<%
String id=request.getParameter("id");
String password=request.getParameter("password");
String name=request.getParameter("name");

ResultSet rs=null;
String sql=null;

try{
	   Class.forName("oracle.jdbc.driver.OracleDriver");
	   Connection  conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20182233","991227");
	   sql="select * from o_member where id=?";
	   PreparedStatement pstmt=conn.prepareStatement(sql);
	   pstmt.setString(1, id);
	   
	   rs=pstmt.executeQuery(); //결과 가져옴
	  
	  if(rs.next()){
	  String dbPass=rs.getString("password");
	  	if(password.equals(dbPass)){
	  	pstmt=conn.prepareStatement("update o_member set name=?, id=? where password=?");
		                                    //UPDATE 테이블명 SET 컬럼명=새로운값 WHERE 업데이트조건 
		pstmt.setString(1,name);
		pstmt.setString(2,id);
		pstmt.setString(3,password);
		  
		pstmt.executeUpdate();

		out.println("회원 정보가 수정되었습니다.");
		}else{
			out.println("회원 정보 수정에 실패했습니다.");}
	}else{
		out.println("회원 정보 수정에 실패했습니다.");
	}

}catch(Exception e){
e.printStackTrace();
}finally{
}
%>
</div>
<br>
</td>
</tr>

<tr>
<td><div style="font-size:15px; text-align:center; color:gray; padding:5px;">이용하실 서비스를 선택해주세요.</div></td>
</tr>

<tr>
<td style="border:1px solid;">
<div style="font-size:17px; text-align:center; padding:5px;">
<A href="http://localhost:8080/PSY/Fin/editForm.jsp">회원 정보 수정</A>
</div>
</td>
</tr>

<tr>
<td style="border:1px solid;">
<div style="font-size:17px; text-align:center; padding:5px;">
<A href="http://localhost:8080/PSY/Fin/list.jsp">회원 정보 목록</A>
</div>
</td>
</tr>

<tr>
<td style="border:1px solid;">
<div style="font-size:17px; text-align:center; padding:5px;">
<A href="http://localhost:8080/PSY/Fin/main.jsp">메인 화면</A>
</div>
</td>
</tr>

</table>

</form>
</body>
</html>