<!--#include file="include/conn.asp"-->
<% 
'website:http://www.angelasp.com
' Angel工作室技术开发团队:QQ:815657032、QQ：709047174
' Copyright (C) Angel工作室 (http://www.angelasp.com).  All rights reserved

if request("action") = "login" then
		call userlogin()
elseif request("action")="logout" then
		call userlogout()
end if

Function userlogout()
Response.Cookies("Auser")("id")=""
Response.Cookies("Auser")("UserName")=""
Response.Cookies("Auser")("UserPass")=""
Response.Cookies("Auser")("Ip")=""
Response.redirect "index.asp"
End Function

Function userlogin()
UserName = trim(request.form("username"))
PassWord = trim(request.form("password"))
if UserName="" then
   response.write "<script language='JavaScript'>alert('用户不能为空！');location='index.asp';</script>"
   response.end
end if
if PassWord="" then
   response.write "<script language='JavaScript'>alert('密码不能为空！');location='index.asp';</script>"
   response.end
End If

Set rs = Server.CreateObject("ADODB.Recordset")
sql="Select id, user_name,user_password,user_ip From [bookuser] where 1=1 and user_name='" &UserName&"' and user_password='" &PassWord&"'"
rs.Open sql,conn,1,3
if rs.bof then
   response.write "<script language='JavaScript'>alert('用户名或者密码错误！');location='index.asp';</script>"
   response.End 
Else 
Response.Cookies("Auser")("id")=rs("id")
Response.Cookies("Auser")("UserName")=rs("user_name")
Response.Cookies("Auser")("UserPass")=rs("user_password")
Response.Cookies("Auser")("Ip")=rs("user_ip")
End If
Response.redirect "index.asp"
rs.close
set rs=Nothing
End Function


%>