<%@ 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" %>
    
    <% String pass=request.getParameter("pass");
    String id=request.getParameter("id");
    String Newname=request.getParameter("name");
    String Newpass=request.getParameter("upass");
    String NewEmailf=request.getParameter("emailf");
    String NewEmailb=request.getParameter("emailb");
%>
    
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<% 
    try{
    	Class.forName("oracle.jdbc.driver.OracleDriver");
		Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20182224","990804");
		PreparedStatement pt=conn.prepareStatement("select * from R_MEMBER");
		ResultSet rs=pt.executeQuery();
		
    	while(rs.next()){
    		if(id.equals(rs.getString("USERID")) && pass.equals(rs.getString("USERPASS"))){
    			pt=conn.prepareStatement("UPDATE R_MEMBER SET USERNAME='"+Newname+"',USERPASS='"+Newpass+"',EMAILF='"+NewEmailf+"',EMAILB='"+NewEmailb+"' WHERE USERID='"+id+"'");
    			rs=pt.executeQuery();
    			session.invalidate();
				%><script>
				alert("변경을 완료했습니다.다시 로그인 해주세요.");
				location.href="../main.jsp";</script><%
    		}else{
    			%><script>
    			alert("변경에 실패했습니다.");
    			location.href="../form/updatef.jsp";</script><%
    		}
    		
    	}
    	
    }catch(Exception e){
    	e.printStackTrace();
    	%><script>
		alert("변경에 실패했습니다.");
		location.href="../form/updatef.jsp";</script><%
    }
    
    %>
</body>
</html>