我原来的代码为:
<!--#include file="conn2.asp"-->
<%
dim name,cards,phone,time,network,level,rs
Name=htmlencode(request.form("Name"))
cards=htmlencode(request.form("cards"))
phone=htmlencode(request.form("phone"))
time=htmlencode(request.form("time"))
network=htmlencode(request.form("network"))
level=htmlencode(request.form("level"))
If name="" or cards="" or phone="" then
Response.Write "<script>alert('持卡人、卡号,电话不能为空!');this.location.href='vbscript:history.back()';;</SCRIPT>"
ElseIf len(Name)>5 or len(cards)<21 then
Response.Write "<script>alert('持卡人、卡号输入错误!');this.location.href='vbscript:history.back()';</SCRIPT>"
ElseIf len(cards)<21 or len(phone)>13 or len(time)>40 or len(network)>40 then
Response.Write "<script>alert('卡号必须是19位!、联系电话、必须填写!');this.location.href='vbscript:history.back()';</SCRIPT>"
ElseIf len(time)>100 then
Response.Write "<script>alert('申请日期不要大于100个字符!');this.location.href='vbscript:history.back()';</SCRIPT>"
ElseIf len(level)>400 then
Response.Write "<script>alert('其它资料不要大于400个字符!');this.location.href='vbscript:history.back()';</SCRIPT>"
Else
Set Rs= Server.CreateObject("adodb.recordSet")
Rs.open "Select * from data", conn, 1, 3
Rs.addnew
Rs("Name") = Name
Rs("cards") = cards
Rs("phone") = phone
Rs("network") = network
Rs("time") = time
Rs("level") = level
Rs("ip") = request.serverVariables("remote_host")
Rs.update
Rs.close
Set Rs = nothing
Response.Write "<script>alert('VIP卡申请成功');this.location.href='add.asp';</SCRIPT>"
Response.End
End If
closedb
%>
现在我想要验证“cards”项内的卡号是否有录入重复,如何重复,则提示并跳转到指定的页面。请高手们帮忙修改一下送分为谢!
数据
------解决方案--------------------
Rs.open "Select * from data WHERE cards='" & cards & "'", conn, 1, 3
IF Not rs.EOF Then
Response.Write "重复cards"
Else
Rs.addnew
Rs("Name") = Name
Rs("cards") = cards
Rs("phone") = phone
Rs("network") = network
Rs("time") = time
Rs("level") = level
Rs("ip") = request.serverVariables("remote_host")
Rs.update
Rs.close
Set Rs = nothing
Response.Write "<script>alert('VIP卡申请成功');this.location.href='add.asp';</SCRIPT>"
Response.End
End If
End If