论坛: 网站建设 标题: asp中怎么调用自己配置的函数? 复制本贴地址    
作者: zbasic [zbasic]    论坛用户   登录
自己做了个判断输入字符是否符合条件的函数,如下

<%
function cutname(str)

if len(trim(str))=0 then
cutname="<br>软件名称不能为空<a href='javascript:history.go(-1);'>"&"点击返回"&"<br>"
else
dd=array("~","!","@","#","$","%","^","&","*","(",")","\","/","?")
for i=0 to 13
temp1=dd(i)
for n=1 to len(str)
temp2=mid(str,n,1)
if temp1=temp2 then
cutname= "<br>软件名不能有特殊字符<a href='javascript:history.go(-1);'>"&"返回"&"<br>"
end if
next
next
end if
if len(trim(str))>20 then
cutname="<br>软件名过长<a href='javascript:history.go(-1);'>"&"点击返回"
end if
end function
%>


调用的代码为

<%
soft_name=cutname(request.Form("soft_name"))
response.Write(soft_name)
sql="insert into soft_down(soft_name) values('"&soft_name&"')"
conn.execute sql
%>

但是这样写如到数据库中soft_name值为空。。。那错了吗?

地主 发表时间: 04-08-20 16:01

回复: qiezic [qiezic]      登录

你又没返回值,soft_name当然就为空了吗!

有空是多看点书!

B1层 发表时间: 04-08-20 18:06

回复: qiezic [qiezic]      登录
<%
function cutname(str,return)
return=str
if len(trim(str))=0 then
cutname="<br>软件名称不能为空<a href='javascript:history.go(-1);'>"&"点击返回"&"<br>"
return="error"
else
dd=array("~","!","@","#","$","%","^","&","*","(",")","\","/","?")
for i=0 to 13
temp1=dd(i)                            '这块算化太烂!
for n=1 to len(str)
temp2=mid(str,n,1)
if temp1=temp2 then
cutname= "<br>软件名不能有特殊字符<a href='javascript:history.go(-1);'>"&"返回"&"<br>"
return="error"
end if
next
next
end if
if len(trim(str))>20 then
cutname="<br>软件名过长<a href='javascript:history.go(-1);'>"&"点击返回"
return="error"
end if
end function

return=""
call cutname(request.Form("soft_name"),return)
soft_name=return
if soft_name<>"error" then
sql="insert into soft_down(soft_name) values('"&soft_name&"')"
conn.execute sql
end if
%>

B2层 发表时间: 04-08-20 18:22

回复: zbasic [zbasic]   论坛用户   登录
因为刚学asp。不到1个月。所以错误百出。。谢谢了。。。真心谢谢!!!

B3层 发表时间: 04-08-21 21:50

论坛: 网站建设

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号