📄 savedata.asp
字号:
<!--made by 中华软件联盟 http://www.softsbest.com/-->
<!--#include file="dbconnect/guestbook.inc.asp" -->
<!--#include file="inc/char.inc.asp"-->
<%
sub getInput()
sName=request.form("Name")
sEmail=request.form("Email")
sHomePage=request.form("HomePage")
sOicq=request.form("Oicq")
sIp=request.ServerVariables("REMOTE_ADDR")
sPic=request.form("Pic")
stxthead=request.form("txthead")
sSubject=request.form("Subject")
sMemo=request.form("Memo")
end sub
Function checkenter()
If sName="" then
checkenter=FALSE
ErrorMsg="<li>你好像忘了填“昵称”,</li><a href=javascript:history.go(-1)>返回上一页</a>"
else
if sEmail="" or InStr(2,sEmail,"@")=0 then
checkenter=FALSE
ErrorMsg="<li>你的Email有问题请重新填写,</li><a href=javascript:history.go(-1)>返回上一页</a>"
else
if sPic="" then
checkenter=FALSE
ErrorMsg="<li>你的头像没选,选一个把,</li><a href=javascript:history.go(-1)>返回上一页</a>"
else
if stxthead="" then
checkenter=FALSE
ErrorMsg="<li>你的表情没选,选一个把,</li><a href=javascript:history.go(-1)>返回上一页</a>"
else
if sMemo="" or len(trim(sMemo))>250 then
checkenter=FALSE
ErrorMsg="<li>留言不能为空并且不能超过250字,重新来吧,</li><a href=javascript:history.go(-1)>返回上一页</a>"
else
checkenter=TRUE
end if
end if
end if
end if
End If
End Function
dim rs
dim sName
dim sEmail
dim sSubject
dim sOicq
dim sIp
dim sPic
dim stxthead
dim sHomePage
dim sMemo
dim errorMsg
dim foundError
getInput()
a=checkenter()
if a = true then
saveData()
if foundError=false then
response.redirect "default.asp"
else
call showerrors()
end if
set rs=nothing
conn.close
set conn=nothing
else
call showerrors()
end if
sub saveData()
dim InsertCursor
Set InsertCursor = Server.CreateObject("ADODB.Recordset")
InsertCursor.Open "select * from book",conn,1,3
InsertCursor.addnew
InsertCursor("name") =htmlencode(sName)
InsertCursor("email") =htmlencode(sEmail)
InsertCursor("homepage") =htmlencode(sHomePage)
InsertCursor("face") ="images/"&sPic&".gif"
InsertCursor("txthead") ="images/"&stxthead&".gif"
InsertCursor("subject") =htmlencode(sSubject)
InsertCursor("memo") =htmlencode(sMemo)
InsertCursor("oicq") =htmlencode(sOicq)
InsertCursor("ip") =sIp
InsertCursor("time") =now()
InsertCursor.Update
InsertCursor.close
conn.close
set InsertCursor=nothing
if err>0 then
err.clear
foundError=true
ErrorMsg="<li>数 据 库 操 作 失 败 !</li>"
else
foundError=false
end if
end sub
sub showErrors()
%>
<html>
<head>
<style type="text/css">
<!-
td{font-size:12px;}
body{font-size:12px;line-height:17px;}
a:link{text-decoration:none;color:#008040}
a:visited{text-decoration:none;color:#008040}
a:active{text-decoration:none}
a:hover { color:#FF8040; text-decoration: underline}
->
</style>
<title>发现错误</title>
</head>
<body>
<p align="center">留言本</p>
<p align="center"><span style="font-size: 9pt"><font color="#0080FF"><%=ErrorMsg%> </font></span></p>
</body>
</html>
<%end sub%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -