<!--#include file="../Inc/Cls_DB.asp" -->
<!--#include file="../Inc/Const.asp" -->
<!--#include file="../Inc/Md5.asp" -->
<%
Dim DBC,Conn
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
if Request.Form("action")="Check" then
	MemName = Replace(Trim(Request.Form("MemName")),"'","''")
	Password = md5(Request.Form("MemPass"),16)

if MemName = "" or  Password = "" then 
	Response.write"<script>alert(""用户名和密码不能为空"");location.href=""javascript:history.back()"";</script>"
	Response.end
end if

Set RsLoginObj = Server.CreateObject("ADODB.RecordSet")
SqlLogin = "Select * from members where MemName='"&MemName&"' and  password='"&Password&"'"
RsLoginObj.Open SqlLogin,Conn,1,1
if Not RsLoginObj.EOF then 
   if RsloginObj("Lock")=true then
	   Response.write"<script>alert(""您已经被锁定，请联系管理员"");location.href=""javascript:history.back()"";</script>"
	   Response.end
   end if
   Session("MemName") = MemName
   Session("MemPassWord") = Password
   Session("MemID") = RsLoginObj("ID")
   Session("GroupID") = Cstr(RsLoginObj("GroupID"))
   Response.Cookies("Foosun")("MemName") = MemName
   Response.Cookies("Foosun")("MemPassword") = Password
   Response.Cookies("Foosun")("GroupID") = RsLoginObj("GroupID")
   dim LoginTime
   LoginTime = Now()
   conn.execute("Update members set LoginNum=LoginNum+1,Point=Point+1,LastLoginIP='"&Request.ServerVariables("Remote_ADDR")&"',LastLoginTime='"&LoginTime&"' where MemName='"&MemName&"'")'用户登陆一次，积分+1分
   Response.Redirect("UserIndex.asp") 
   Response.End
else
   Response.write"<script>alert(""非法登陆！请检查用户名和密码的正确性"");location.href=""javascript:history.back()"";</script>"
   Response.end
end if
set Conn = Nothing
Set RsLoginObj = Nothing

end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>会员中心</title>
<style type="text/css">
<!--
 BODY   {border: 0; margin: 0; cursor: default; font-family:宋体; font-size:9pt;}
 BUTTON {width:5em}
 TABLE  {font-family:宋体; font-size:9pt}
 P      {text-align:center}
-->
</style>
</head>
<body leftmargin="0" topmargin="0">
<%
MemName = Session("MemName")
PassWord = Session("MemPassWord")
MemID = Session("MemID")
set RsMemObj = Server.CreateObject ("ADODB.RecordSet")
RsMemObj.Source="select * from Members where MemName='"& MemName &"' and password='"&PassWord&"'"
RsMemObj.Open RsMemObj.Source,Conn,1,1
if not RsMemObj.EOF then
%>
<table width="226" border="0" cellpadding="2" cellspacing="0">
  <tr> 
    <td colspan="4" class="tabbgcolorlileft"><span class="Nred9pt"><%=session("memname")%></span>：欢迎您！<a href="Usermain.asp" target="_top">会员中心</a> 
      <a href="Logout1.asp">退出</a> </td>
  </tr>
  <tr> 
    <td width="67"> <div align="right">积分：</div></td>
    <td width="36"><%=RsMemObj("Point")%></td>
    <td width="60">登陆次数：</td>
    <td width="47"><%=RsMemObj("LoginNum")%></td>
  </tr>
  <tr> 
    <td width="67"> <div align="right">注册时间：</div></td>
    <td colspan="3"><%=RsMemObj("RegTime")%></td>
  </tr>
  <tr> 
    <td width="67"> <div align="right">登陆时间：</div></td>
    <td colspan="3"><%=RsMemObj("LastLoginTime")%></td>
  </tr>
  <tr> 
    <td width="67"> <div align="right">登陆ＩＰ：</div></td>
    <td colspan="3"><%=RsMemObj("LastLoginIP")%></td>
  </tr>
  <tr> 
    <td colspan="4"><a href="UserModify.asp?action=ChangePwd&MemID=<%=RsmemObj("ID")%>" target="_top">修改密码</a>　　<a href="UserModify.asp?action=Modify&MemID=<%=RsmemObj("ID")%>" target="_top">修改资料</a>　　<a href="UserModify.asp?action=Other&MemID=<%=RsmemObj("ID")%>" target="_top">修改密码问题</a> 
    </td>
  </tr>
</table>
<%
else
%>
<table width="100%" border="0" cellspacing="5" cellpadding="0">
  <form action="" method="post" name="LoginForm">
    <tr> 
      <td> 
        <div align="center">用户： 
          <input name="MemName" type="text" id="MemName" size="15">
      </div></td>
    </tr>
    <tr> 
      <td> 
        <div align="center">密码： 
          <input name="MemPass" type="password" id="MemPass" size="15">
      </div></td>
    </tr>
    <tr> 
      <td><div align="center">
          <input type="submit" name="Submit" value="登录">
          <input type="reset" name="Submit2" value="重置">
          <input name="action" type="hidden" id="action" value="Check">&nbsp;&nbsp;
          <a href="Reg.asp" target="_top"><font color="#FF0000">注册</font></a> 
          <a href="UserForGet.asp" target="_top">忘记密码</a></div></td>
    </tr>
  </form>
</table>
  <%
end if
%>
</body>
</html>
