<body>
<%
set rst=server.CreateObject("adodb.recordset")
rst.open "zxly",conn,1,3
rst.addnew
rst("kname")=trim(request.Form("name"))
rst("ktel")=trim(request.Form("tel"))
rst("ktitle")=trim(request.Form("zhuti"))
%>
<%
if Not CheckFrom(request.form("liuyanneirong")) then
response.Write " <script LANGUAGE='javascript'>alert('非法操作,请输入中文');history.go(-1);/script>"
response.End
end if
Function CheckFrom(str)
CheckFrom = False
n=0
for i=1 to len(str)
whichChar = mid(str,i,1)
if abs(asc(whichChar))>127 then
n=n+1
'Response.write whichChar & "是一个汉字"
if n>3 then
CheckFrom = true
exit for
end if
end if
next
End Function
%>
<%
if trim(request.Form("yanzhengma"))="" And CStr(Session("GetCode")) <> CStr(request.Form("yanzhengma")) then
response.Write "<script> alert('请返回输入正确的验证码,谢谢合作!');history.back();</script>"
end if
rst.update
rst.close
set rst=nothing
response.Write "<script> alert('提交成功!我们会及时给您回复,请浏览本站查收...');window.location.href='http://www.guidepost-china.com/zxly.asp';</script>"
%>
</body>
</html>
上面写的对吗?可是为什么数据库中没有数据呢?
[Quote=引用 1 楼 lzp4881 的回复:]
<%
if Not CheckFrom(request.form("content")) then
'response.Write " <script LANGUAGE='javascript'>alert('非法操作');history.go(-1);/script>"
response.End
end if
Function CheckFrom(str)
CheckFrom = False
n=0
for i=1 to len(str)
whichChar = mid(str,i,1)
if abs(asc(whichChar))>127 then
n=n+1
'Response.write whichChar & "是一个汉字"
if n>3 then
CheckFrom = true
exit for
end if
end if
next
End Function
%>
[/Quote]
上面的代码如果在验证都是中文的情况下如何把内容写入到数据库呢?应该放在什么地方写
<%
if Not CheckFrom(request.form("content")) then
'response.Write "<script LANGUAGE='javascript'>alert('非法操作');history.go(-1);/script>"
response.End
end if
Function CheckFrom(str)
CheckFrom = False
n=0
for i=1 to len(str)
whichChar = mid(str,i,1)
if abs(asc(whichChar))>127 then
n=n+1
'Response.write whichChar & "是一个汉字"
if n>3 then
CheckFrom = true
exit for
end if
end if
next