菜鸟告急!!!!找大虾帮忙!
我的代码验证用户名有没有重复,但我又想让它验证身份证号有没有重复。
就是既验证用户名又要验证身份证号
<%
response.cookies("ip")=request.servervariables("remote_addr")
userid=request("userid")
password=request("password")
password2=request("password2")
name=request("name")
Province=request("Province")
city=request("city")
qq=request("qq")
tel=request("tel")
card=request("card")
postcard=request("postcard")
adress=request("adress")
mobile=request("mobile")
sex=request("sex")
email=request("email")
if userid="" then
response.write "<script>alert('用户名字段空白,不接受!');history.back();</Script>"
response.end
end if
if password="" then
response.write "<script>alert('密码字段空白,不接受!');history.back();</Script>"
response.end
end if
if len(tel)<7 then
response.write "<script>alert('电话号码有误,不接受!');history.back();</Script>"
response.end
end if
if len(postcard)<6 then
response.write "<script>alert('邮政编码有误,不接受!');history.back();</Script>"
response.end
end if
if name="" then
response.write "<script>alert('姓名字段空白,不接受!');history.back();</Script>"
response.end
end if
if city="" then
response.write "<script>alert('城市字段空白,不接受!');history.back();</Script>"
response.end
end if
if adress="" then
response.write "<script>alert('地址字段空白,不接受!');history.back();</Script>"
response.end
end if
if email="" then
response.write "<script>alert('邮件字段空白,不接受!');history.back();</Script>"
response.end
end if
if instr(email,"@")=0 or right(email,1)="@" or left(email,1)="@" then
response.write "<script>alert('email字段错误,请重新输入!');history.back();</Script>"
response.end
end if
if password<>password2 then
response.write "<script>alert('两次密码输入不相同,不接受!');history.back();</Script>"
response.end
end if
set rs=server.createobject("adodb.recordset")
sql="select userid from users where userid='"&userid&"'"
rs.open sql,conn,2,2
if not rs.eof then
response.write "<script>alert('这一“用户名称”已被占用,请得新输入!');history.back();</Script>"
response.end
end if
%>
<%
dim rs
dim sql1
set rs=server.createobject("adodb.recordset")
sql1="select * from users"
rs.open sql1,conn,2,2
rs.addnew
rs("userid")=userid
rs("password")=password
rs("name")=name
rs("Province")=Province
rs("city")=city
rs("qq")=qq
rs("card")=card
rs("tel")=tel
rs("postcard")=postcard
rs("mobile")=mobile
rs("point")=100
rs("adress")=adress
rs("sex")=sex
rs("email")=email
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
请问大虾我应该怎么改!!!
问题点数:20、回复次数:2Top
1 楼possible_Y(████本人签名需要刮开,方可看到 )回复于 2003-06-01 11:32:58 得分 20
set rs=server.createobject("adodb.recordset")
sql="select userid from users where userid='"&userid&"'"
rs.open sql,conn,2,2
if not rs.eof then
response.write "<script>alert('这一“用户名称”已被占用,请得新输入!');history.back();</Script>"
response.end
end if
改为
-------------------》
sql="select userid from users where userid='"&userid&"'"
set rs=conn.execute(sql)
if not rs.eof then
response.write "<script>alert('这一“用户名称”已被占用,请得新输入!');history.back();</Script>"
response.end
end if
rs.Close
sql="select userid from users where card='"&card&"'"
set rs=conn.execute(sql)
if not rs.eof then
response.write "<script>alert('身份证号重复');history.back();</Script>"
response.end
end if
rs.CloseTop
2 楼forestyang(forestyang)回复于 2003-06-01 11:37:45 得分 0
之前再判断一下card输入是否为空,还有数据库要加入这个字段,呵呵
set rs=server.createobject("adodb.recordset")
sql="select userid,card from users where userid='"&userid&"' or card='"&card&"'"
rs.open sql,conn,2,2
if not rs.eof then
response.write "<script>alert('这一“用户名称”已被占用或此身分号码已存在,请得新输入!');history.back();</Script>"
response.end
end if
Top




