<!--#include file="../conn.asp"-->
<!--#include file="../md5.asp"-->
<%
		dim rs,sql,username,userpsd,verycode
		username=request.Form("username")
		userpsd=request.Form("userpsd")
		
    if username="" or userpsd="" then
	response.write errma("登陆失败","请正确填写登陆信息!")
  	Response.End 
	end if
			
    if request("verycode")="" then
    response.write errma("登陆失败","验证验证码不正确!")
  	Response.End 
	elseif session("AskGetCode")="9999" then
    session("AskGetCode")=""
	elseif session("AskGetCode")="" then
    response.write errma("登陆失败","验证验证码不正确!")
 	Response.End 
	elseif cstr(session("AskGetCode"))<>cstr(trim(request("verycode"))) then
    response.write errma("登陆失败","验证验证码不正确!")
	Response.End 
	end if
		
		set rs=server.CreateObject("adodb.recordset")
		sql ="Select * from kw_admin where username='"&username&"' and userpsd='"&md5(userpsd,16)&"'"
        rs.open sql,conn,1,1
        if rs.eof and rs.bof then
				rs.close
		        set rs=nothing
		        closedb
	         response.write errma("登陆失败","用户名或密码不正确!")
  	         Response.End 
		else
		session("kwadmin")=username
		session("userflag")=rs("userflag")
		session("uid")=rs("id")
		        rs.close
		        set rs=nothing
		        closedb
		response.write "<script language=javascript>alert('欢迎登陆!');document.location.href='index.asp'</script>"
		end if
		
function errma(errbt,errnr)
dim errstr
errstr="<html>"&vbcrlf
errstr=errstr&"<head>"&vbcrlf
errstr=errstr&"<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"&vbcrlf
errstr=errstr&"<title>操作反馈</title>"&vbcrlf
errstr=errstr&"<link href=""css.css"" rel=""stylesheet"" type=""text/css"">"&vbcrlf
errstr=errstr&"</head>"&vbcrlf
errstr=errstr&"<body>"&vbcrlf
errstr=errstr&"<br>"&vbcrlf
errstr=errstr&"<br>"&vbcrlf
errstr=errstr&"<br>"&vbcrlf
errstr=errstr&"<table width=""360"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""1"" bgcolor=""#CCCCCC"" class=""login"">"&vbcrlf
errstr=errstr&"<tr bgcolor=""#0066CC"">"&vbcrlf
errstr=errstr&"<td height=""30"" align=""center""><font color=""#FFFFFF""><b>"&errbt&"</b></font></td>"&vbcrlf
errstr=errstr&"</tr>"&vbcrlf
errstr=errstr&"<tr>"&vbcrlf
errstr=errstr&"<td height=""104"" bgcolor=""#FFFFFF"" align=""center"">"&errnr&"&nbsp;&nbsp;&nbsp;&nbsp;<a href=login.asp><font color=red>- 返 回 -</font></a></td>"&vbcrlf
errstr=errstr&"</tr>"&vbcrlf
errstr=errstr&"</table>"&vbcrlf
errstr=errstr&"</body>"&vbcrlf
errstr=errstr&"</html>"&vbcrlf
response.Write(errstr)
end function
%>