aj短裤:注册页面验证已注册用户的ASP语句

来源:百度文库 编辑:高校问答 时间:2024/05/02 18:34:38
注册页面验证已注册用户的ASP语句

<%
username=trim(request.form("username")) '取提交页 username 文本框数据 即用户名 并定义为变量username
password=trim(request.form("password")) '取提交页 password 文本框数据 即密码 并定义为变量password
password_=trim(request.form("password_")) '取提交页 password 文本框数据 即重复密码 并定义为变量password_

set rs=conn.execute("select*from user where username='"&username&"'") 'SQL语句,查询表user取字段username等变量username

if username="" or password="" or password_="" then '判断提交页数据是否为空
response.write"错误!用户名称、密码必须添写!<a href=reg.asp>返回</a>"
else

if not rs.eof or username="admin" then '判断表内是否有该用户存在 如存在则提示错误信息
response.write"错误!该用户已经存在请换其他的用户名!<a href=admin_adduser.asp>返回</a>" '提示错误信息
else '否则

if password<>password_ then '判断两次输入的密码是否一样
response.write"错误!两次密码输入的不正确!<a href=reg.asp>返回</a>"
else

set sql=conn.execute("Insert Into user(username,password) Values ('"&username&"','"&password&"')") '一切无误存入数据库表 user
set sql=nothing
response.redirect("index.asp") '跳转到 index.asp 页
end if
end if
end if
%>

'号 后面的为注释!!

username=trim(request.form("username"))
sql="select * from table where user='"&username&"'"
如果有记录,表示用户存在,不能注册