<!--#include file="conn.asp"-->
<%
Dim UserName,UserPass
UserName=replace(trim(Request.Form("Username")),"'","‘")
UserPass=replace(trim(Request.Form("Userpass")),"'","‘")

If UserName="" or UserPass="" Then
	Response.Write ("<script>alert(' 会员登陆失败!\n\n  请输入用户名和密码。');history.back();</script>")
	Response.end
End If

userip1 = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
userip2 = Request.ServerVariables("REMOTE_ADDR")
If userip1 = "" Then
	userip = userip2
Else
	userip = userip1
End If 

set rs=server.createobject("adodb.recordset")
sql="select password,loginIP,logintime,sex,name from [ylmv_user] where username='"&UserName&"' and lockuser=0"
rs.open sql,conn,1,3
if rs.eof then
	Response.Write ("<script>alert(' 会员登陆失败!\n\n    用户名不存在。');history.back();</script>")
	Response.end
else
	if rs("password")<>UserPass then
		rs.close
		set rs=nothing
		Response.Write ("<script>alert(' 会员登陆失败!\n\n    密码输入错误。');history.back();</script>")
		Response.end
	else
		rs("loginIP")=userip
		logintime=NOW()
		rs.update
	        session("UserName")=UserName
	        session("TrueName")=rs("Name")
		session("PassWord")=UserPass
		session("sex")=rs("sex")
		session.timeout=200
	end if
end if

rs.close
set rs=nothing
CloseDatabase
response.redirect(request.servervariables("HTTP_REFERER"))
%>