这个简单:
<%
...
do while not Rs.eof
if Rs("username")=Trim(Request.Form("username")) then
response.write "很抱歉,该帐号已经被注册,请换一个帐号,谢谢!<a href=javascript:history.go(-1)>返回</a>"
response.end
end if
Rs.MoveNext
loop
...
%>
<!--#include file="conn.asp"-->
<!--#include file="md5.asp"-->
<%dim username,userpassword,comeurl
username=replace(trim(request("username")),"'","")
userpassword=md5(replace(trim(request("userpassword")),"'",""))
if trim(request("comeurl"))="" then
comeurl="index.asp"
else
comeurl=trim(request("comeurl"))
end if
if username="" or userpassword="" then
response.Write "<center><a href=login.asp><font color=red size=2>对不起,登陆失败,请检查您的登陆名和密码</font></a></center>"
response.end
end if
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from [user] where username='"&username&"' and userpassword='"&userpassword&"' " ,conn,1,3
if not(rs.bof and rs.eof) then
if userpassword=rs("userpassword") then
response.Cookies("shop")("username")=trim(request("username"))
'response.Cookies("shop").expires=date+1
rs("lastlogin")=now()
rs("logins")=rs("logins")+1
rs.Update
rs.Close
set rs=nothing
call loginok()
else
response.write "<script LANGUAGE='javascript'>alert('对不起,您的用户名或密码有误!');window.location.reload('javascript:history.go(-1)')</script>"
end if
else
response.write "<script LANGUAGE='javascript'>alert('对不起,您的用户名或密码有误!');window.location.reload('javascript:history.go(-1)')</script>"
end if
sub loginok()
response.Write "<font size=2>欢迎您 <font color=red size=2>"&request.Cookies("shop")("username")&"</font>,两秒种后将自动跳转到相应页!</font>"
response.Write "<meta http-equiv=refresh content=2;URL="&comeurl&">"
end sub
%>
rstsql="select * from TABLE where USER = '"& request("USER") &"'"
rstobj.open rstsql,conndb
if not rstobj.eof then
response.write "人家用啦,你歇歇吧。"
else
rstobj.addnew
...
rstobj.update
end if
rstsql="select * from TABLE where USER = '"& request("USER") &"'"
rstobj.open rstsql,conndb
if not rstobj.eof then
response.write "人家用啦,你歇歇吧。"
else
rstobj.addnew
...
rstobj.update
end if