<%@ 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 userid=request.getParameter("userid");
    String Password=request.getParameter("Password");
    String name=request.getParameter("name");
    String str="";
    String sql="";
   
    
    try{
    	Class.forName("oracle.jdbc.driver.OracleDriver");
		Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20182226","991214");
		PreparedStatement pstmt=conn.prepareStatement("select * from MEMBER_2A");
		   ResultSet rs= pstmt.executeQuery();
	    str="성공";
	    
	    
	    while(rs.next()){
	    	if(userid.equals(rs.getString("id")) && Password.equals(rs.getString("Password"))){
	    session.setAttribute("userid", userid);
	    session.setAttribute("Password",Password);
	  
	    response.sendRedirect("list.jsp");
	    break;
	    	}
	    	else{
	    		 str="no";   
	    	}
	    
	    }
	   	sql="update MEMBER_2A set name=? where id=?";
		pstmt=conn.prepareStatement(sql);
		pstmt.setString(1,name);
		pstmt.setString(2,userid);
		pstmt.executeUpdate();
		pstmt.executeQuery();
 	 
    }catch(Exception e){
    	e.printStackTrace();

    }
    %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body bgcolor="lightblue">
<%=str %>
 <A href="http://localhost:8080/Test_Project/aa/aaa.jsp"> 홈으로</A>
</body>
</html>