<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.sql.*,gbase.db.*" %>
<%
	String message="";
	String forget_flag="";
	String email1="";
	String password1="";
	String enter_user_id=request.getParameter("enter_user_id")==null?"":request.getParameter("enter_user_id").trim();
	String username=request.getParameter("username")==null?"":request.getParameter("username").trim();
	String email=request.getParameter("email")==null?"":request.getParameter("email").trim();
	String url="/index.html";
	
	String sql = " select * from enter_user_user where username=? and enter_user_id=?";
	
        DBOperation theDBOperation = new DBOperation();
        DBConnection dbConnection = new DBConnection();
        Connection conn=dbConnection.getConnection();
        PreparedStatement stmt=conn.prepareStatement(sql);
        stmt.setString(1,username);
        stmt.setString(2,enter_user_id);
        
      try {
        ResultSet rs1=stmt.executeQuery();
        if(rs1.next())
        {
        email1=rs1.getString("email");
        password1=rs1.getString("password");
        }
        if(email1.equals(email))
          {
          message = "操作成功,请到您的邮箱接收您的密码！";
          SendMail send=new SendMail();
          send.SendMail("关于工号"+username+"找回密码的通知!","您的企业帐号为:"+enter_user_id+",工号为:"+username+",密码为:"+password1,email1);
          forget_flag="true";
          }
        else
          {message = "您的企业帐号、工号与邮箱不相符，请重新输入！";
          forget_flag="false";}
      }
      catch (Exception ex) {
        message = "操作失败!";
        forget_flag="false";
      }
      finally{
      if(stmt!=null && (!conn.isClosed()))stmt.close();
      if(conn!=null && (!conn.isClosed()))conn.close();
      }
	
%>
<script language="javascript">
	function process (message, forget_flag,url){
		alert(message);
		if(forget_flag=='false')
		  self.location = "/forget.jsp";
		else
		  self.location="/index.html";
	}
</script>
<html>
	<head>
		<title>用户注册</title>
	</head>
	<body onload="javascript: process('<%=message%>','<%=forget_flag%>','<%=url%>');">
	</body>
</html>