<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.sql.*,gbase.db.*,java.util.*" %>
<%
	
	String message="";
	String login_flag="";
	String password1="11221122111111";
	String enter_name="";
	String enter_user_name="";
	String domain_name=request.getParameter("domain_name")==null?"":request.getParameter("domain_name").trim();
	String username=request.getParameter("username")==null?"":request.getParameter("username").trim();
	String password=request.getParameter("password")==null?"":request.getParameter("password");
	
	String sql = " select a.password as password,b.name as enter_name,a.name as enter_user_name from enter_user_user a,enter_user b where a.username=? and a.enter_user_id=? and a.enter_user_id=b.username";
	
        DBOperation theDBOperation = new DBOperation();
        DBConnection dbConnection = new DBConnection();
        Connection conn=dbConnection.getConnection();
        PreparedStatement stmt=conn.prepareStatement(sql);
        stmt.setString(1,username);
        stmt.setString(2,domain_name);
        ResultSet rs1=null;
      try {
        rs1=stmt.executeQuery();
        if(rs1.next())
        {
        password1=rs1.getString("password");
        enter_name=rs1.getString("enter_name");
        enter_user_name=rs1.getString("enter_user_name");
        }
        if(password1.equals(password))
          {
          message = "操作成功!";
          session.setAttribute("enter_username",domain_name);
          session.setAttribute("enter_name",enter_name);
          session.setAttribute("enter_user_username",username);
          session.setAttribute("enter_user_name",enter_user_name);
          session.setAttribute("new118kf","login_ok");
          login_flag="true";
          }
        else
         { message = "登录失败!";
          login_flag="false";
          }
      }
      catch (Exception ex) {
        message = "登录失败!";
        login_flag="false";
      }
      finally{
      if(rs1!=null)rs1.close();
      if(stmt!=null && (!conn.isClosed()))stmt.close();
      if(conn!=null && (!conn.isClosed()))conn.close();
      
      }
	
%>
<script language="javascript">
	function process ( login_flag,message){
		if(login_flag=='false')
		{
		alert(message);
		//self.location = "/";
		window.close();
		}
		else
		{
		//self.location = "/server/chat.jsp";
		window.open("/server/chat.jsp","在线客服","width=707,height=464,resizable=0,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no,fullscreen=no");
		}
	}
</script>
<html>
	<head>
		<title>用户登录</title>
	</head>
	<body onload="javascript: process('<%=login_flag%>','<%=message%>');">
	</body>
</html>