如何使用asp遍历数组 实现单用户多密码登陆

来源:百度知道 编辑:UC知道 时间:2024/06/22 14:10:48
我使用的是ASP+access,想要实现单用户多密码登陆,比如说我设置一个用户名:admin。那么密码我想设置多个,比如:123,456,789,……
任意一个密码与用户名配合都能验证成功。

有朋友给出建议,说是使用遍历数组。

数据库:admin 123,456,789
ASP:读出 rs("pwd")用 遍历数组 分割逗号 分别是 123 456 789 然后判断

本人尚属初学者,想请各位高人写出可以参考使用的asp代码,谢谢了。

*************************
admin 123
admin 456
admin 789
……
数据库这样设计的就免了,本人也会
*************************

1楼的 好像没读懂题目..

设:拿到的帐号变量为 u 密码变量为 p

....
sql = "select user,pass from admin where user='" & u & "'"
set rs = conn.execute(sql)

if rs.eof then
response.write("找不到该用户!")
response.end
end if

dim check,arr
check = false
arr = split(rs("pass"),"|")
for i = 0 to ubound(arr)
if p=arr(i) then
check = true
exit for
end if
next

if not check then
response.write("密码错误")
response.end
end if

'这里就是 帐号密码都通过后执行的........

假设数据库读取出来密码是:123,456,789
dim pwd,pass,i,password
password=用户登陆表单传递过来的密码

pwd=rs("pwd")

首先分割密码:
pass=split(pwd,",")
for i=0 to ubound(pass)
if password<>pass(i) then
response.write "这里是禁止登陆,否则可以登陆。"
response.end()
end if
next

当然MD5加密对比就不说