⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 booksavedata.asp

📁 商店程序 商店程序 商店程序 商店程序 商店程序 商店程序
💻 ASP
字号:
<%@ LANGUAGE="VBSCRIPT" %>
<%option explicit
Response.Cookies("UserInfo")("UserName")=trim(Request.Form("txtName"))
Response.Cookies("UserInfo")("UserEmail")=trim(request.form("txtEmail"))
Response.Cookies("UserInfo")("homepage")=trim(request.form("txtHomePage"))
Response.Cookies("UserInfo").Expires = now() + 365
%>
<!--#include file="conn.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+"&lt;"
	 case ">"
	 result=result+"&gt;"
 case chr(13)
	 result=result+"<br>"
	 case chr(34)
	 result=result+"&quot;"
	 case "&"
	 result=result+"&amp;"
 case chr(32)	 
	 'result=result+"&nbsp;"
	 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+"&nbsp;"
	 else
	 result=result+" "
	 end if
	 else
	 result=result+"&nbsp;"	 
	 end if
	 case chr(9)
	 result=result+" "
	 case else
	 result=result+mid(str,i,1)
 end select
 next 
 htmlencode2=result
 end function

dim WINNT_CHINESE
WINNT_CHINESE=(len("网辰留言")=4)
function strLength(str)
 if WINNT_CHINESE then
 dim l,t,c
 dim i
 l=len(str)
 t=l
 for i=1 to l
 c=asc(mid(str,i,1))
 if c<0 then c=c+65536
 if c>255 then
 t=t+1
 end if
 next
 strLength=t
 else 
 strLength=len(str)
 end if
 end function 

sub chkInput()
	if Trim(sName)="" then
	 sName="匿名"
		elseif strLength(sName)>=50 then
	 foundError=true
		 ErrorMsg=ErrorMsg+"<li>您 输 入 的 “大 名” 的 长 度 不 能 大 于 50 !</li>"
	 end if
	 if strLength(sEmail)>255 then
 	 foundError=true
		 ErrorMsg=ErrorMsg+"<li>您 输 入 的 “E-Mail” 的 长 度 不 能 大 于 255 !</li>"
	 end if
	 if Trim(sTitle)="" then
 sTitle="<无主题>"
 elseif strLength(sTitle)>255 then
 	 foundError=true
		 ErrorMsg=ErrorMsg+"<li>您 输 入 的 “主 题” 的 长 度 不 能 大 于 255 !</li>"
	 end if
	 if strLength(sHomePage)>255 then
 	 foundError=true
		 ErrorMsg=ErrorMsg+"<li>您 输 入 的 “主 页” 的 长 度 不 能 大 于 255 !</li>"
	 end if
	 if Trim(sInput)="" then
 	 foundError=true
 ErrorMsg=ErrorMsg+"<li>没 有 留 言 , 请 留 下 您 的 宝 贵 意 见 !</li>"
	 elseif strLength(sInput)>16384 then
 	 foundError=true
		 ErrorMsg=ErrorMsg+"<li>您 输 入 的 “留 言” 的 长 度 不 能 大 于 16384 (16K)!</li>"
	 end if
 end sub

sub getInput()
 sName=request.form("txtName")
	 sEmail=request.form("txtEmail")
	 sHomePage=request.form("txtHomePage")
	 sFace=request.form("face")
	 sTitle=request.form("txtTitle")
	 sInput=request.form("txtContent")
	 end sub
%>
<%
 dim sql
 dim rs

 dim sName
 dim sEmail
 dim sTitle 
 dim sFace
 dim sHomePage
 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
 set rs=nothing 
 conn.close
 set conn=nothing
end if
 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("email") =htmlencode2(sEmail)
 InsertCursor("homepage") =htmlencode2(sHomePage)
 InsertCursor("face") =sFace&".gif"
 InsertCursor("title") =htmlencode2(sTitle)
 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 NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=gb2312">
<title>输 入 有 错 </title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>

<p>不 能 保 存 留 言 !       
      
<ul>      
 <font color="#0080FF"><%=ErrorMsg%>      
</font>      
</ul>      
<!--#include file="guestbook.asp"-->      
<%end sub%>      
<%sub success()      
response.write "<html> <head><meta HTTP-EQUIV=refresh Content='2;url=book.asp'>"      
response.write "<title>留 言 成 功</title>"      
response.write "</head><body>"      
response.write "<br><br><center><font size=5 color=navy><b>您 已 经 成 功 留 下 了 宝 贵 意 见 !<br>"      
response.write "<br>谢 谢 您 的 留 言 ! </b></font>"      
response.write "<br><br>2秒后将自动 <a href=book.asp>返 回</a></center>"      
response.write "</body></html>"      
end sub%>      
</body>      
</html>      

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -