asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0
假定用户名是username,密码是userpass,数据库表名是userinfo
密码采用md5加密

<!-- #include file="MD5.asp" -->
<%
dim connstr,conn,sql,rs

dim username,userpass
'打开数据库,以下为示例
Connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db1.mdb")
Set conn=Server.CreateObject("ADODB.Connection")
conn.open ConnStr

'获取传入的参数
username=request.form("username")
userpass=request.form("userpass")

'对传入的参数赋值
username=trim(username)
username=replace(username,"'","") '最必须的过滤,其它需要做的处理查其它资料

userpass=trim(userpass)
userpass=md5(userpass) '非MD5加密的就不要这句

'读取数据库记录
sql="select top 1 userpass from [userinfo] where username='"&username&"'"
set rs=conn.execute(sql)

'判断
if rs.eof then
response.write("用户名错")
response.end
else
if rs("userpass")<>userpass then
response.write("密码错")
response.end
else
response.write("验证通过")
'进行必要处理,比如写入cookie/session等
end if
end if

rs.close
set rs=nothing


'关闭数据库
conn.close
set conn=nothing
%>
posted on 2006-07-25 16:34 汪杰 阅读(199) 评论(0)  编辑 收藏 引用 所属分类: asp(javascrpt)
只有注册用户登录后才能发表评论。

<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 456688
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜