📄 save.asp
字号:
<%@ LANGUAGE="VBSCRIPT" %>
<%option explicit
%><!--#include file="bkconn.asp"-->
<%
function htmlencode2(str)
dim result
dim l
if isNULL(str) then
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case "<"
result=result+"<"
case ">"
result=result+">"
case chr(13)
result=result+"<br>"
case chr(34)
result=result+"""
case "&"
result=result+"&"
case chr(32)
'result=result+" "
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else
result=result+" "
end if
else
result=result+" "
end if
case chr(9)
result=result+" "
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function
sub chkInput()
if Trim(sName)="" then
sName="匿名"
elseif len(sName)>=50 then
foundError=true
ErrorMsg=ErrorMsg+"您 输 入 的 “昵称” 的 长 度 不 能 大 于 50 !"
end if
if len(sEmail)>50 then
foundError=true
ErrorMsg=ErrorMsg+"您 输 入 的 “E-Mail” 的 长 度 不 能 大 于 50 !"
end if
if Trim(sTitle)="" then
sTitle="<无对方昵称>"
elseif len(sTitle)>50 then
foundError=true
ErrorMsg=ErrorMsg+"您 输 入 的 “电话” 的 长 度 不 能 大 于 50 !"
end if
if len(sHomePage)>50 then
foundError=true
ErrorMsg=ErrorMsg+"您 输 入 的 “主 页” 的 长 度 不 能 大 于 50 !"
end if
if Trim(sInput)="" then
foundError=true
ErrorMsg=ErrorMsg+"没 有 数 据 , 请 填 写 完 整!"
elseif len(sInput)>300 then
foundError=true
ErrorMsg=ErrorMsg+"你的留言存在广告嫌疑!"
end if
end sub
sub getInput()
sName=trim(request.form("txtName"))
sxingming=trim(request.form("txtxingming"))
sdizhi=trim(request.form("txtdizhi"))
swangyou=trim(request.form("txtwangyou"))
sInput=trim(request.form("txtContent"))
end sub
%>
<%
dim sql
dim rs
dim sName
dim sxingming
dim sdizhi
dim snianling
dim swangyou
dim sInput
dim foundError
dim errorMsg
getInput()
chkInput()
if foundError then
call showErrors()
else
saveData()
if foundError then
call showErrors()
else
call success()
end if
end if
set rs=nothing
conn.close
set conn=nothing
sub saveData()
on error resume next
dim cmdTemp
dim InsertCursor
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set InsertCursor = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT * FROM book where name is null"
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = conn
InsertCursor.Open cmdTemp, , 1, 3
InsertCursor.addnew
InsertCursor("name") =htmlencode2(sName)
InsertCursor("xingming") =htmlencode2(sxingming)
InsertCursor("dizhi") =htmlencode2(sdizhi)
InsertCursor("wangyou") =htmlencode2(swangyou)
InsertCursor("content") =htmlencode2(sInput)
InsertCursor("time") =cstr(now())
InsertCursor.Update
InsertCursor.close
conn.close
set InsertCursor=nothing
set conn=nothing
if err>0 then
err.clear
foundError=true
ErrorMsg="<li>怎么这么没诚意 !</li>"
end if
end sub
sub showErrors()
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="style.css">
<title>输 入 有 错 啦</title>
<script language="JavaScript">
function CheckForm()
{
if (document.regform.txtname.value filter=/^\s*[A-Za-z0-9]\s*$/; length == 0) {
alert("请输入对方的城市.");
document.regform.txtname.focus();
return false;
}
if (document.regform.txtdizhi.value.length == 0) {
alert("请输入您城市.");
document.regform.txtdizhi.focus();
return false;
}
if (document.regform.txtwangyou.value.length == 0) {
alert("请输入对方的名字.");
document.regform.txtwangyou.focus();
return false;
}
if (document.regform.txtxingming.value.length == 0) {
alert("请输入你的名字.");
document.regform.txtxingming.focus();
return false;
}
if (document.regform.txtContent.value.length == 0) {
alert("你的行为非常嫌疑,我们拒绝您的留言.");
document.regform.txtContent.focus();
return false;
}
}
</script>
<style type="text/css">
<!--
body {
background-color: #FFCCFF;
}
-->
</style></head>
<body>
<p><strong><font color="#FFFFFF">不 能 保 存 数 据!</font></strong>
<ul>
<font color="#0080FF"><%=ErrorMsg%>
</font>
</ul>
<div align="center"></div>
<h5> </h5>
</body>
</html>
<%end sub%>
<%sub success()%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../style.css">
<title>提交成功</title>
</head>
<body>
<br><br><center><font size=5 color=navy>你的留言存在广告嫌疑,将由管理员审核后发表!<br>
<br>请耐心等待管理员审核最长时间为24小时! </font>
<br><br><a href="javascript:self.close()">关闭窗口</a>
</center>
</body>
</html>
<%end sub%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -