但是数据库中已经存在了下载专用登陆器这个数据,如果提交的话就会出现response.write "<script>alert('当前提交的服务器名或IP在数据库里已经存在\n请重新检查后提交,请不要提交重复信息');history.back()</script>",没有则将记录写入数据库!
该怎么弄啊谢谢!
原始代码
<!--#include file="config.asp"-->
<!--#include file="conn.asp"-->
<!--#include file="code.asp"-->
<%
set rs = server.createobject("adodb.recordset")
dim name,ip,gameid,daikuan,renshu,startdate,Stime,addr,xingzhi,main,homepage,download
name=htmlencode(request("name"))
ip=htmlencode(request.form("ip"))
gameid=htmlencode(trim(request.form("gameid")))
daikuan=htmlencode(trim(request.form("daikuan")))
Service=htmlencode(trim(request.form("Service")))
renshu=htmlencode(trim(request.form("renshu")))
Sdate=request.form("Sdate")
addr=htmlencode(request.form("addr"))
xingzhi=htmlencode(request.form("xingzhi"))
main=htmlencode(request.form("main"))
addname=htmlencode(request.form("addname"))
email=htmlencode(request.form("email"))
homepage=htmlencode(request.form("homepage"))
download=htmlencode(request.form("download"))
if name="" or ip="" or gameid="" or daikuan="" or Service="" or renshu="" or Sdate="" or main="" or xingzhi="" or addr="" then
response.write "<script>alert('带*的选项必须填写或选择,请返回检查后再提交');history.back()</script>"
response.end
end if
if int(daikuan)>ubound(split(dsign,",")) or int(renshu)>ubound(split(rsign,",")) or int(Service)>ubound(split(Ssign,",")) then
response.write "<script>alert('非法数据,请勿试图提交非法参数');history.back()</script>"
response.end
end if
call add()
sub add()
sql="SELECT * FROM sfdata where ip='"&ip&"'"
rs.open sql,conn,1,1
if rs.bof and rs.eof then
rs.close
sql="select * from sfdata"
rs.open sql,conn,1,3
rs.addnew
rs("name")=name
rs("ip")=ip
rs("gameid")=gameid
rs("daikuan")=daikuan
rs("Service")=Service
rs("renshu")=renshu
rs("Sdate")=Sdate
rs("addr")=addr
rs("xingzhi")=xingzhi
rs("main")=main
rs("addname")=addname
rs("email")=email
rs("homepage")=homepage
rs("download")=download
rs("ulock")=SFUlock '1:前台添加私服时自动通过审核;0:前台发布私服后需在后台审核后才能显示。
rs("top")=0
rs.update
name=rs("name")
response.write "<script>alert('服务器"&name&"提交成功\n请等待管理员审核。\n请不要重复发布信息!\n如果信息发布错误需要修改,\n请直接联系管理员。');location.replace('index.asp')</script>"
rs.close
rs.nothing
call closeconn
else
response.write "<script>alert('当前提交的服务器IP在数据库里已经存在\n请重新检查后提交,请不要提交重复信息');history.back()</script>"
rs.close
rs.nothing
call closeconn
end if
end sub
%>
[此贴子已经被作者于2005-12-3 22:07:44编辑过]