<!--#include file="cn.asp"-->
<%
username=trim(request.Form("uid"))
userpassword=trim(request.Form("pwd"))

if username<>"" and userpassword<>"" then
	
	sql="select * from admin where username='"&username&"'"
	cnopen()	
	set rs=server.CreateObject("adodb.recordset")
	rs.open sql,cn,1,2
	if not rs.eof and not rs.bof then
	
		if rs("userpassword")=userpassword then
		
			session.Timeout=300
			session("adminname")=rs("username")
			session("adminid")=rs("id")
		
			cn.execute("update admin set loginnum=loginnum+1,logindate=now() where id="&rs("id")&"")
		
			response.Write("<script>window.location.href='frame.asp';</script>")	
		else
			response.Write("<script>alert('用户名或者密码错误!');history.go(-1);</script>")
		end if
	else
		response.Write("<script>alert('用户名或者密码错误!');history.go(-1);</script>")
	end if
	
	rs.close()
	set rs=nothing
	cnclose()
else
	response.Write("<script>alert('必须填写用户名和密码!');history.go(-1);</script>")
end if


%>
