asp用户注册与登陆验证

 数据库access2003
新用户注册
<%
set conn=server.createobject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0;data

source=" & server.mappath("/News.mdb")
set rs=server.createobject("adodb.recordset")
%>
方法一:
<%
sql="insert into News(用户名,密码,性别,年龄) values(' "

&name& "',' "&password &"','" &sex &"',' " &age& "')"
conn.execute(sql)
rs.close
conn.close

%>
方法二
<%
name=request.form("name")
password=request.form("password")
sex=request.form("sex")
age=request.form("age")
sql="select * from News"
rs.open sql,conn,1,3
rs.addnew
rs("用户名")=name
rs("密码")=password
rs("性别")=sex
rs("age")=age
rs.update
rs.close
conn.close
set rs=nothing
%>
进行登陆验证
在HTML设计表单时,设置用户名:name 密码:pass
<%
name=request.form("name")
pass=request.form("pass")
set conn=server.createobject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0;data

source=" & server.mappath("/News.mdb")
set rs=server.createobject("adodb.recordset")
sql="select * from News where 用户名=' " & name & " ' "
rs.open sql,conn,1,3
if not rs.eof
if rs("用户名")=name and rs("密码")=pass then
response.write "用户成功登陆"
else
response.write "用户或密码错误"
end if
end if
%>

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页