login.asp

来自「网上购物系统」· ASP 代码 · 共 50 行

ASP
50
字号
<!--#include file="conn.asp"-->
<%
action=trim(request.QueryString("action"))
FromURL=trim(request.QueryString("FromURL"))

if action="ok" then

zhanghao=trim(request.form("username"))
     pwd=trim(request.form("userpassword"))

if zhanghao="" or pwd="" then
	response.Write "<script LANGUAGE='javascript'>alert('请输入帐号或密码!');history.go(-1);</script>"
end if
if len(zhanghao)<4 or len(zhanghao)>12 then
	response.Write "<script LANGUAGE='javascript'>alert('帐号不能小于4大于12位!');history.go(-1);</script>"
end if
if len(pwd)<4 or len(pwd)>20 then
	response.Write "<script LANGUAGE='javascript'>alert('密码不能小于4大于20位!');history.go(-1);</script>"
end if

set rs=server.CreateObject("adodb.recordset")
sql="select * from users where uname='"&zhanghao&"' and upassword='"&pwd&"'"
rs.open sql,conn,1,1
if not(rs.bof or rs.eof) then
	if  pwd=rs("upassword")then
    session("userid")=rs("uid")
	session("username")=rs("uname")
	session("uadmin")=rs("uadmin")
		if fromURL="" then		
		response.Redirect "Index.asp"
		else
		response.Redirect fromURL
		end if
	end if
else
	response.Write "<script LANGUAGE='javascript'>alert('对不起!您的帐号或密码错误!');history.go(-1);</script>"
end if

rs.close
set rs=nothing
conn.close
set conn=nothing
end if

if action="out" then
session("userid")=""
response.Write"<script>alert('成功退出登陆!');location.href('index.asp');</script>"
end if
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?