<!--
whilvydy 新闻发布系统
-->

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ include file = "func/parameter.jsp" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %> 
<%@ page import="java.util.*" %>
<jsp:useBean id="LoginBean" scope="page" class="net.jspcn.db.DbConnect" />
<jsp:useBean id='oMD5' scope='page' class='net.jspcn.tool.MD5'/>

<%
if(request.getParameter("user_account")!=null && request.getParameter("user_password")!=null)
{
	String user_account=request.getParameter("user_account");
	String user_password=oMD5.getMD5ofStr(request.getParameter("user_password"));
	
	LoginBean.openConnection();
	String sql = "select * from "+user_table+" where user_account=\""+ user_account +"\" and user_password=\""+ user_password +"\"";
	ResultSet rs = LoginBean.executeQuery(sql);
	if (rs.next()) {
	out.println("in record");
	session.putValue("user_id",rs.getString("user_id"));
	session.putValue("user_account",rs.getString("user_account"));
	session.putValue("user_name",rs.getString("user_name"));
	session.putValue("user_email",rs.getString("user_email"));
	session.putValue("user_mobile",rs.getString("user_mobile"));
	session.putValue("user_qq",rs.getString("user_qq"));
	session.putValue("user_power",rs.getString("user_power"));
	
	String sql_in = "insert into "+logrecord_table+" (logrecord_id,user_name,operation_time,logrecord_operation) values('','"+rs.getString("user_name")+"',now(),'"+rs.getString("user_name")+" login system')";
	LoginBean.executeUpdate(sql_in);
	response.sendRedirect("index.jsp");
	}
	else {
	rs.close();
	String sql_in = "insert into "+logrecord_table+" (logrecord_id,user_name,operation_time,logrecord_operation) values('','"+user_account+"',now(),'"+user_account+" login system faild')";
	LoginBean.executeUpdate(sql_in);
	}
}
%>

<%@ include file = "func/header.jsp" %>
<body>
<h4 align="center">&nbsp;</h4>
<h4 align="center">&nbsp;</h4>
<h4 align="center"><%=webtitle%>登陆:</h4>
<p align="center">&nbsp;</p>
<form action="login.jsp" method=post name=form1 onsubmit="return formCheck()">
  <table width="50%" border="0" cellspacing="5" cellpadding="6" align="center">
    <tr> 
      <td> <div align="center"><font size="2"><b>用户账号:</b></font> 
          <input type="text" name="user_account" class="input" size="18" maxlength="16" onMouseOver=this.focus()>
        </div></td>
    </tr>
    <tr> 
      <td> <div align="center"><font size="2"><b>登陆密码:</b></font> 
          <input type="password" name="user_password" class="input" size="18" maxlength="14" onMouseOver=this.focus()>
        </div></td>
    </tr>
    <tr> 
      <td> <div align="center"> 
          <input name="submit" type="submit" class="button" value="登 陆">
        </div></td>
    </tr>
  </table>
</form>

<SCRIPT language=JavaScript>     
         function formCheck()     
            {if(document.form1.user_account.value=="")     
            {alert("请输入您的帐号!");     
			 document.form1.user_account.focus();      
			 return false;}     
			if(document.form1.user_password.value=="")     
            {alert("请输入您的用户密码!");     
			 document.form1.user_password.focus();      
			 return false;}     
         }     
</SCRIPT>
         
<%
LoginBean.close();
%>
         
<%@ include file = "func/footer.jsp" %>