编程论坛's Archiver

malidong 发表于 2007-11-20 19:16

用户输入字符过滤问题

那位高手帮我一下.在下面的代码中帮忙添加一些过滤非法字符的代码.比如&lt; &gt; $之类的符号.本人非常感谢.<BR><BR>!--#include file=CONN.ASP--&gt;<BR>&lt;%<BR>dim id,username<BR>id=trim(request("id"))<BR>if not isnumeric(id) or id="" then<BR>response.write "&lt;li&gt;参数错误!"<BR>cl<BR>response.end<BR>end if<BR>if request.cookies("ijob")("username")="" or request.cookies("ijob")("domain")="" or request.cookies("ijob")("id")="" then <BR>response.write "&lt;br&gt;"<BR>response.write "&lt;li&gt;你还没有登陆!"<BR>cl<BR>response.end<BR>end if<BR>if request("ijob")="chk" then<BR>call ijob()<BR>response.end<BR>end if<BR>%&gt;<BR>&lt;meta http-equiv="Content-Language" content="zh-cn"&gt;<BR>&lt;link rel="stylesheet" type="text/css" href="1.CSS"&gt;<BR>&lt;title&gt;发送邮件&lt;/title&gt;<BR>&lt;style type="text/css"&gt;<BR>&lt;!--<BR>body {<BR> background-color: #F2F2F2;<BR>}<BR>--&gt;<BR>&lt;/style&gt;&lt;body topmargin="3" leftmargin="0"&gt;<BR>&lt;div align="center"&gt;<BR>  &lt;center&gt;<BR>  &lt;br&gt;<BR>  &lt;br&gt;<BR>  &lt;table width="352" height="64" border="0" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" bgcolor="#F2F2F2" style="border-collapse: collapse"&gt;<BR>    &lt;form action="?id=&lt;%=id%&gt;&amp;ijob=chk" method="POST"&gt;<BR>    &lt;tr&gt;<BR>      &lt;td width="80" height="25" style="border-bottom-style: none; border-bottom-width: medium"&gt;<BR>      &lt;p align="center"&gt;&lt;font color="#FF0000"&gt;回复内容:&lt;/font&gt;&lt;/td&gt;<BR>      &lt;td width="273" height="25" style="border-bottom-style: none; border-bottom-width: medium"&gt;<BR>      &lt;textarea class="inputa" crows="16" name="neirong" cols="37" style="height:150 "&gt;&lt;/textarea&gt;&lt;/td&gt;<BR>    &lt;/tr&gt;<BR>    &lt;tr&gt;<BR>      &lt;td width="353" height="35" colspan="2" style="border-top-style: none; border-top-width: medium"&gt;<BR>      &lt;p align="center"&gt;<BR>      &lt;input class="inputb" type="submit" value="提交回复" name="B1"&gt;&lt;/td&gt;<BR>    &lt;/tr&gt;<BR>    &lt;/form&gt;<BR>  &lt;/table&gt;<BR>  &lt;/center&gt;<BR>&lt;/div&gt;<BR>&lt;%<BR>sub ijob()<BR>dim rs,sql,neirong<BR>if len(trim(request("neirong")))&lt;2 then<BR>response.write "&lt;li&gt;回复内容没有填写!"<BR>cl<BR>response.end<BR>end if<BR>set rs=server.createobject("adodb.recordset")<BR>sql = "select * from hf "<BR>rs.open sql,conn,1,3<BR>rs.addnew<BR>rs("username")=request.cookies("ijob")("username")<BR>rs("neirong")=trim(request("neirong"))<BR>rs("xxid")=id<BR>rs.update<BR>rs.close<BR>set rs=nothing<BR>Conn.Execute("Update xinxi Set hfcs=hfcs+1 where id="&amp;cstr(id))<BR>closedb<BR>response.write "&lt;li&gt;回复成功!"<BR>cl<BR>end sub<BR>%&gt;<BR>&lt;%sub cl()%&gt;<BR>&lt;body&gt;<BR>&lt;%end sub%&gt;

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.