放飞你的梦想--翱翔我的天空 | 会员登陆 | 繁體中文 | 站点地图 | 站长博客
 | 网站首页 | 文章中心 | IT 前沿 | 清怡画风 | 视频教程 | 资源下载 | 精彩图库 | 博客文赏 | 天空论坛 | 访客留言 | 音乐版 | 
    本站全新推出IT 前沿频道欢迎大家访问 地址 http://it.tkbbs.com  [风雪残士  2005年12月9日]            本站推出新浪VIVI收藏夹服务,欢迎使用  [风雪残士  2005年10月18日]        
您现在的位置: 翱翔翼站 >> 文章中心 >> 编程开发 >> 网页开发 >> ASP编程 >> 文章正文 今天是:
flash+asp+xml留言本教程 【字体:
作 者:佚名 文章来源:网络 更新:2006-4-3 16:05:44 点击:







点击下载源文件

   在下载到本地或者上传到空间上之前,请到后台修改参数设置里面的地址,然后进行测试!

   如果你的机器或者服务器不支持FSO,请手动修改URL.XML文件里面的地址!

ASP主要部分:

page.asp (传给flash第n页的n条纪录)

以下是引用片段:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% show_page = 9 '每页显示的纪录
db = "data/data.mdb" '数据库存放目录
'-连接数据库
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath(db)
'-----------------------------------------------------------------------
'用途:将UTF-8编码汉字转为GB2312码,兼容英文和数字!
function encodestr(str)
dim i
str=trim(str)
str=replace(str,"'","""")
str=replace(str,vbCrLf&vbCrlf,"</p><p>")
encodestr=replace(str,vbCrLf,"<br>")
end function
'用途:将UTF-8编码汉字转为GB2312码,兼容英文和数字!
Function uni(Chinese)
For j = 1 to Len (Chinese)
a=Mid(Chinese, j, 1)
uni= uni & "&#x" & Hex(Ascw(a)) & ";"
next
End Function %>
<%
'如果FLASH传过来变量
if request("action")="showpage" then
'打开纪录
sql="select * from gbook order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
'---------------分页 开始
if not rs.eof then
'如果有记录
rs.PageSize = show_page
total=rs.RecordCount '共多少条记录
maxpage=rs.PageCount '共分几页
page=request("page") '当前页
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if
rs.AbsolutePage=Page
else
'如果没记录
total=0
maxpage=0
page=0
out=""
wujilu="1"
'把wujilu变量传给flash,让flash知道没有记录然后做出相应的动作
'输出xml文件格式
Response.Write "<?xml version='1.0' encoding='utf-8'?>"
Response.Write "<gbook total='"&total&"' maxpage='"&maxpage&"' page='"&page&"' wujilu='"&wujilu&"'></gbook>"
Session.CodePage="936"
end if
'---------------分页 结束
'---------------打开 PageSize 条记录 开始
if not rs.eof then
'如果有记录
for i=1 to rs.PageSize
page_id=rs("id")
page_name=uni(rs("name"))
if len(rs("title")) >19 then '截取字符
page_title=left(rs("title"),19)&".."'截取字符
else
page_title=rs("title")
end if
page_title=uni(page_title)
page_date=rs("date")
out=out&"<info page_id='"&page_id&"' page_name='"&page_name&"' page_title='"&page_title&"' page_date='"&page_date&"' />"
rs.movenext
if rs.EOF then
i=i+1
Exit For
end if
next
end if
'---------------打开 PageSize 条记录 结束
rs.close
set rs=nothing
conn.close
set conn=nothing'释放资源
'输出分页信息,xml格式
Response.Write "<?xml version='1.0' encoding='utf-8'?>"
Response.Write "<gbook total='"&total&"' maxpage='"&maxpage&"' page='"&page&"'>"&out&"</gbook>"
Session.CodePage="936"
end if
%>

show.asp(传给flash单条纪录的信息)

以下是引用片段:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
show_page = 9 '每页显示的纪录
db = "data/data.mdb" '数据库存放目录
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath(db)
'-----------------------------------------------------------------------
'用途:将UTF-8编码汉字转为GB2312码,兼容英文和数字!
function encodestr(str)
dim i
str=trim(str)
str=replace(str,"'","""")
str=replace(str,vbCrLf&vbCrlf,"</p><p>")
encodestr=replace(str,vbCrLf,"<br>")
end function
Function uni(Chinese)
For j = 1 to Len (Chinese)
a=Mid(Chinese, j, 1)
uni= uni & "&#x" & Hex(Ascw(a)) & ";"
next
End Function
'------------------------------------------------------------
%>
<%
if request("action")="show" then
'打开纪录为flash传过来的第show_id条信息
sql="select * from gbook where id="&request("show_id")
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
'uni参数,就是把gb编码转换成utf-8编码,要不然flash会乱码
show_name=uni(rs("name"))
show_id=uni(rs("id"))
show_title=uni(rs("title"))
if rs("email")<>"" then
show_email=uni(rs("email"))
end if
if rs("qq")<>"" then
show_qq=uni(rs("qq"))
end if
show_content=uni(rs("content"))
show_date=uni(rs("date"))
out=out&"<info show_name='"&show_name&"' show_id='"&show_id&"' show_title='"&show_title&"' show_email='"&show_email&"' show_qq='"&show_qq&"' show_content='"&show_content&"' show_date='"&show_date&"' />"
rs.close
set rs=nothing
conn.close
set conn=nothing
'输出xml格式
Response.Write "<?xml version='1.0' encoding='utf-8'?>"
Response.Write "<gbook>"&out&"</gbook>"
end if
%>

add.asp(flash传给asp增加纪录)

以下是引用片段:
<%
show_page = 9 '每页显示的纪录
db = "data/data.mdb" '数据库存放目录
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath(db)
'-----------------------------------------------------------------------
'用途:将UTF-8编码汉字转为GB2312码,兼容英文和数字!
function encodestr(str)
dim i
str=trim(str)
str=replace(str,"'","""")
str=replace(str,vbCrLf&vbCrlf,"</p><p>")
encodestr=replace(str,vbCrLf,"<br>")
end function
Function uni(Chinese)
For j = 1 to Len (Chinese)
a=Mid(Chinese, j, 1)
uni= uni & "&#x" & Hex(Ascw(a)) & ";"
next
End Function
'------------------------------------------------------------
%>
<%
Session.CodePage="65001"
if encodestr(request("action"))="add" then'如果flash传过来的变量是add
if encodestr(request("w_name"))="" then'如果w_name等于空
cuowu="n"
response.write"&addok="+cuowu '
elseif encodestr(request("w_title"))="" then '如果标题空
cuowu="t"
response.write"&addok="+cuowu
elseif encodestr(request("w_content"))="" then'如果留言内容空
cuowu="c"
response.write"&addok="+cuowu
end if
if cuowu="" then '如果姓名,标题,留言内容不为空
sql="select * from gbook "
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,3,3
rs.addnew '增加纪录
rs("name")=encodestr(request("w_name"))
rs("title")=encodestr(request("w_title"))
if encodestr(request("w_email"))="" then
rs("email")=null
else
rs("email")=encodestr(request("w_email"))
end if
if encodestr(request("w_qq"))="" then
rs("qq")=null
else
rs("qq")=encodestr(request("w_qq"))
end if
rs("content")=encodestr(request("w_content"))
rs("date")=date()
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
response.write"&addok=ok" '返回给flash 留言成功
end if
end if
Session.CodePage="936"
%>
 

[1] [2] 下一页



文章录入:风雪残士    责任编辑:风雪残士 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    相关文章
    没有相关文章
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    最新文章 TOP10
    最新热门 TOP10
    最新推荐TOP10
    翱翔翼站拥有本站所有版权! Copyright © 2005 - 2008 5-IT.COM
    本站维护 :风雪残士

    浙ICP备05039908号
    努力打造国内最全的电脑技术资料库