<%@ 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");%>
<%
String id=request.getParameter("id");
String passwd1=request.getParameter("passwd1");
String passwd2=request.getParameter("passwd2");
String name=request.getParameter("name");
String tel=request.getParameter("tel");
String post=request.getParameter("post");
String address=request.getParameter("address");
String email=request.getParameter("email");

String str="";
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","20162499","980202");
	   sql="select * from member where id=? ";
	   PreparedStatement pstmt=conn.prepareStatement(sql);
	   pstmt.setString(1, id);
	    rs=pstmt.executeQuery(); //결과 가져옴
	  
	  if(rs.next()){
	  String dbPass=rs.getString("password");
	  
	  if(passwd1.equals(dbPass)){
		 
	  	  pstmt=conn.prepareStatement("update member set password=?,  name=?, tel=?,address1=?,address2=?,email=? where id=?");
		                                               //UPDATE 테이블명 SET 컬럼명=새로운값 WHERE 업데이트조건                                           		   
		  pstmt.setString(1,passwd2);
		  pstmt.setString(2,name);
		  pstmt.setString(3,tel);
		  pstmt.setString(4,post);
		  pstmt.setString(5,address);
		  pstmt.setString(6,email);
		  pstmt.setString(7,id);
		  
		  
		  
		  pstmt.executeUpdate();
		  str="정보변경 성공하였습니다.";
	 }else{
		 str="정보변경에 실패하였습니다.";
	 }}
	  else{
		  str="존재하지않는 아이디";
	  }

}catch(Exception e){
e.printStackTrace();
}finally{
}


%>

<!doctype html>
<html>
<head>
<meta charset="UTF-8">

<title>로그인</title>
<link href="member.css" rel="stylesheet" type="text/css">

</head>
<body>
<div id="web">
 <div class="top">
 <div class="top_space">
 <div class="top_manu">
 <ul>
 <li>
 <a href="main.jsp"> 
 <span class="homeIcon"></span>메인페이지</a>
    </li>
    <li>
    <a href="logOut.jsp">
    <span class="loginIcon"></span>로그아웃</a>
    </li>
    <li>

 <a href="memberForm.jsp"><span class="signIcon"></span>회원가입</a>
 </li>
 </ul>
 </div></div><hr style="border:solid 0.7px #BDBDBD;"></div>

 
  <main id="main">
  <div class="main_bgspace1">
 <div class="main_bgsize1">
  <div class="main_updatebg">
  </div>
 </div>
 </div>
   <div class="main_tablespace">
 <div class="main_tablesize">
  <div class="main_table ">
<table border="0" width="500" height="180"  align="center" cellspacing="0" >
<tr><td ><%=str %></td></tr>
<tr><td><br><input type="button" class="btn2" value="돌아가기 " style="height:60px; width:500px;" onclick="location.href='update.jsp'"></td></tr>
<tr><td><br><input type="button" class="btn2" value="정보수정 확인" style="height:60px; width:500px;" onclick="location.href='list.jsp'"></td></tr>
<tr><td><br><input type="button" class="btn2" value="메인페이지 " style="height:60px; width:500px;" onclick="location.href='main.jsp'"></td></tr>
</table>
 </div>
 </div>
 </div>
 </main>
 <bottom id="bottom">
 </bottom>
 </div>
</body>
</html>

