ASP验证登录页代码问题

来源:百度知道 编辑:UC知道 时间:2024/05/30 22:46:40
从a.asp页面填写用户名,密码,按提交转到这个页面 b.asp 验证,可我这段代码有问题,不管用户名,密码是对是错都能通过,高手帮忙看看
<%

if request.ServerVariables("request_method")="post" then
dim userid,userpwd,nickname
dim sql1,sql2,sql3,sql4
userid=request.Form("uid")
userpwd=request.Form("pwd")
nickname=request.Form("nickname")
set conn3=server.createobject("ADODB.Connection")
connstr="driver={Microsoft Access Driver (*.mdb)};dbq="&Server.MapPath("/adb/dada.mdb")
conn3.Open connstr
sql1="select userid,pwd from if where userid='"&useri &"'and pwd='"&userpwd&"'"
set myrecord0=conn3.execute(sql1)
if myrecord0.eof or myrecordo.bof then
response.Write("密码或账号输入错误!<a href='index.asp'>请重新登录</a>")
response.write("<p>如果您还没有注册,请先<a href='newuser.asp'>注册</a>

//敲个验证的函数给你//
<%
'checklogin() 登陆验证函数
'参数说明 username,用户名 password,密码

function checklogin(username,password)
if username<>"" then
Dim rs,sql
sql = "select * from 表名 where [用户名字段]='"&username&"'"
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
if password<>"" then
if password=rs(密码字段) then
response.cookies("loginUser")=rs("ID")
isLogin = 1 '登陆成功
else
isLogin = 3 '密码错误
end if
else
isLogin = 2 '密码没有填写
end if
else
isLogin = 0 '您输入的用户名不存在
end if
else
isLogin = -1 '用户名没有填写
end if
rs.close
checklogin = isLogin
end function

'Msg() 弹出信息窗口函数
'参数说明 Err,错误信息 url,跳转 sts,跳转方式(1按url跳转,2返回上页)
function Msg(Err,url,sts)
response.write "<sc