| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1568 人关注过本帖
标题:[求助]一段程序不明白请教大家
只看楼主 加入收藏
wuyunshan
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2005-11-27
收藏
得分:0 
正是这个意思
但是数据库中已经存在了下载专用登陆器这个数据,如果提交的话就会出现response.write "<script>alert('当前提交的服务器名或IP在数据库里已经存在\n请重新检查后提交,请不要提交重复信息');history.back()</script>",没有则将记录写入数据库!
该怎么弄啊谢谢!
2005-11-30 16:15
wuyunshan
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2005-11-27
收藏
得分:0 
2005-11-30 16:15
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
收藏
得分:0 

如果是“下载专用登陆器”,就不需要判断了,直接执行写入数据操作!
<%
if ip="下载专用登陆器" then
写入数据库
else
查询数据库,判断是否有重复的ip
if 有
response.write "<script>alert('当前提交的服务器名或IP在数据库里已经存在\n请重新检查后提交,请不要提交重复信息');history.back()</script>"
else
写入数据
end if
end if
%>


专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
2005-11-30 16:32
wuyunshan
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2005-11-27
收藏
得分:0 
代码要怎么写啊
我总是写不对,总是出现错误啊?
2005-11-30 16:46
wuyunshan
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2005-11-27
收藏
得分:0 

原始代码
<!--#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-11-30 16:46
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
收藏
得分:0 
<!--#include file="config.asp"-->
<!--#include file="conn.asp"-->
<!--#include file="code.asp"-->
<%
set rs = server.createobject("adodb.recordset")
dim names,ip,gameid,daikuan,renshu,startdate,Stime,addr,xingzhi,main,homepage,download
names=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
if ip="下载专用登陆器" then
call addsf()
else
sql="SELECT * FROM sfdata where ip='"&ip&"'"
rs.open sql,conn,1,1
flag=rs.RecordCount
if flag>0 then
response.write "<script>alert('当前提交的服务器IP在数据库里已经存在\n请重新检查后提交,请不要提交重复信息');history.back()</script>"
else
call addsf()
end if
end if
'定义写入记录的函数sddsf()
function addsf()
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
response.write "<script>alert('服务器"&names&"提交成功\n请等待管理员审核。\n请不要重复发布信息!\n如果信息发布错误需要修改,\n请直接联系管理员。');location.replace('index.asp')</script>"
end function
rs.close
rs.nothing
call closeconn
%>

专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
2005-11-30 17:00
wuyunshan
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2005-11-27
收藏
得分:0 

非常感谢谢谢!

[此贴子已经被作者于2005-11-30 17:32:10编辑过]

2005-11-30 17:31
wuyunshan
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2005-11-27
收藏
得分:0 

有点错误啊
把所有的都填写上以后点提交出现:带*的选项必须填写或选择,请返回检查后再提交

2005-11-30 17:38
wuyunshan
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2005-11-27
收藏
得分:0 
谢谢,谢谢,已经完全好了非常感谢
我要好好学习了呵呵!
2005-11-30 17:40
wuyunshan
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2005-11-27
收藏
得分:0 
<!--#include file="config.asp"-->
<!--#include file="conn.asp"-->
<!--#include file="code.asp"-->
<%
set rs = server.createobject("adodb.recordset")
dim names,ip,gameid,daikuan,renshu,startdate,Stime,addr,xingzhi,main,homepage,download
names=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
if ip="下载专用登陆器" then
call addsf()
else
sql="SELECT * FROM sfdata where ip='"&ip&"'"
rs.open sql,conn,1,1
flag=rs.RecordCount
if flag>0 then
response.write "<script>alert('当前提交的服务器IP在数据库里已经存在\n请重新检查后提交,请不要提交重复信息');history.back()</script>"
else
call addsf()
end if
end if
'定义写入记录的函数sddsf()
function addsf()
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
response.write "<script>alert('服务器"&names&"提交成功\n请等待管理员审核。\n请不要重复发布信息!\n如果信息发布错误需要修改,\n请直接联系管理员。');location.replace('index.asp')</script>"
end function
rs.close
rs.nothing
call closeconn
%>


这段程序有时候用的挺好的,但是有的时候就不行了,点击了提交以后出现没有反映的问题,不知道为什么,希望能帮我解决一下谢谢!

[此贴子已经被作者于2005-12-3 22:07:44编辑过]

2005-12-03 21:44
快速回复:[求助]一段程序不明白请教大家
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021592 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved