用ASP制作留言板一定要链接数据库吗
不一定。可以将留言信息保存到一个文本文件中,这时就不用连接数据库。也可以将留言信息保存到一个数据库文件中,这时就一定要连接数据库啦。
ASP留言版怎么实现
我刚好有,分给我,加QQ我发给你 本留言板是一个简单的ASP留言板,主要由三文件组成,分别为 主页index.asp 、 写留言记录的write.asp 、记录所有留言的数据库messages.mdb。 本留言板使用的Access数据库保存数据,适用于小型的个人网站。另外,本留言板的源码也可以给 ASP的初学者作参考之用。
谁给我对ASP留言板的心得?
ASP留言板就相当于博客一样啊。。就是用户给你留言了然后你可以回复(相当于论坛格局得,看你要不要回复了),而这个功能主要得问题是布局上得问题。。其他得数据都是从数据库取得。。主要是布局格式没问题了。。一个留言板就出现了
dreamweaver,asp怎么制作留言板
需要动态网页开发技术,不知道你目前学的怎么样。先要架设安装IIS服务器,用来解析ASP程序,下载安装一个数据库,你可以使用SQL server数据库。
创建一个asp文件,里面创建留言标题,留言人信息,手机号,留言内容等,使用代码连接数据库,代码如下。
%
Dim Database
Database="datamessage"
Dim Conn,ConnStr
Set conn = Server.CreateObject("ADODB.Connection")
ConnStr="Provider=sqloledb;Server=localhost;database="Database";uid=sa;pwd="
Conn.open ConnStr
%
再次新建一个名为:default.asp的文件,这个文件是显示和添加留言的页面
编码也需要改为GB2312
在这里输入的代码如下:
!--#include file="conn.asp"--
%
if request("action")="addmessagesave" then
if trim(request("memo"))="" then
Response.Write("script lanuage=javascriptalert('留言内容不能为空!');location='message.asp'/script")
response.End()
End if
set rsa=Server.CreateObject("ADODB.RecordSet")
strsqla="select * from [message]"
rsa.open strsqla,conn,3,2
rsa.addnew
rsa("memo")=request("memo")
rsa("time1")=now
rsa.update
Response.Write("script lanuage=javascriptalert('留言成功!');location='message.asp'/script")
response.End()
End if
%
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312" /
title在线留言/title
style
*{margin:0px;padding:0px;font-size:14px;color:#000000;}
a{font-size:14px;color:#999999;}
body{margin:0 auto;line-height:30px;}
/style
/head
body
table width="930" height="553" border="0" align="center" cellpadding="0" cellspacing="0"
tr
td width="230" valign="top" align="center"
br/br/br/
a href="manage.asp"留言管理/a
br/br/
/td
td width="700" height="553" valign="top" align=left
留言 div class=height9 /div
br/br/
br/
%
message
addmessage
%
/td
/tr
/table
/body
/html
%
sub addmessage()
%
form id="form1" name="form1" method="post" action="?action=addmessagesave"
table width="519" height="200" border="0"
tr
td width="94" height="55"nbsp;/td
td width="415"
input type="hidden" name="dd" value="0" checked="checked"/ /td
/tr
tr
td height="104" align=center内容:/td
tdlabel
textarea name="memo" cols="50" rows="6" /textarea
/label/td
/tr
tr
td height="33"nbsp;/td
td
input type="submit" name="Submit" value="提交" / /td
/tr
/table
/form
%
end sub
SUB message()
set rs=Server.CreateObject("ADODB.RecordSet")
sql="select * from message order by id desc"
rs.open sql,conn,1,1
if rs.eof then
if request("key")"" then
response.write("div style=""text-align:center""没有查到您要查找的留言!/div")
else
response.write("div style=width:500px;height:50px;text-align:center暂时没有留言留言!/div")
End if
else
response.write("div ")
PERPAGE=10
if request("pageno")="" or isNumeric(request("pageno"))=0 or request("pageno")"1" then
curpage = 1
else
curpage = cint(request("pageno"))
end if
rs.pagesize = PERPAGE
if curpagers.pagecount then curpage=rs.pagecount
rs.absolutepage = curpage
for i=1 to rs.pagesize
if rs.eof then
exit for
end if
%
table width="553" height="100" border="0" cellpadding="0" cellspacing="0" bgcolor=#ffffff style="border:1px solid #cccccc;margin-left:10px;margin-top:5px;"
tr
td style="padding-left:20px;"[内容]/td
td class="6702-a0e3-423b-db97 xb-a04"%=rs("memo")%/td
tdnbsp;/td
/tr
tr
td height="31" style="padding-left:20px;"/td
td class="a0e3-423b-db97-631f xb-a04"%
%/td
td[时间:%=rs("time1")%]/td
/tr
%if rs("hui")"" then%
tr
td style="padding-left:20px;"[回复]/td
td colspan="2" class="423b-db97-631f-1cdb xb-a04" align="left"nbsp;nbsp;%=rs("hui")%/td
/tr
%End if%
/table
%
rs.movenext
next
if curpage = 1 then
response.write "/divBRdiv style=width:440px;height:30px;text-align:center 首页 | 上一页 | "
else
response.write "/divBRdiv style=width:440px;height:30px;text-align:center; a href='?pageno=1'首页/a | a href='?pageno="curpage-1"leixing="leixing"'上一页/a | "
end if
if curpage = rs.pagecount then
response.write "下一页 | 尾页/div"
else
response.write "a href='?pageno="curpage+1"leixing="leixing"'下一页/a | a href='?pageno="rs.pagecount"leixing="leixing"'尾页/a/div"
end if
rs.close
end if
End sub
%
新建一个管理留言的页面,名为manage.asp
同样先改编码为GB2312去掉原来的代码重新输入新的代码如下:
!--#include file="conn.asp"--
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""
html
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
title无标题文档/title
style type="text/css"
!--
body {font-size: 12px; color: #000000; font-family: 宋体}
td {font-size: 12px; color: #000000; font-family: 宋体;}
.t1 {font:12px 宋体;color=000000}
.t2 {font:12px 宋体;color:ffffff}
.bt1 {font:14px 宋体;color=000000}
.bt2 {font:14px 宋体;color:ffffff}
A:link {color: #000066}
A:visited {color: #000066}
A:hover {color: #ff0000}
A.r1:link {font-size:12px;text-decoration:underline;color:#000000;}
A.r1:visited {font-size:12px;text-decoration:underline;color:#000000;}
A.r1:hover {font-size:12px;text-decoration:underline;color:#ff0000;}
A.r2:link {font-size:12px;text-decoration:underline;color:#ffffff;}
A.r2:visited {font-size:12px;text-decoration:underline;color:#ffffff;}
A.r2:hover {font-size:12px;text-decoration:underline;color:#ff6600;}
A.r3:link {font-size:12px;text-decoration:none;color:#000000;}
A.r3:visited {font-size:12px;text-decoration:none;color:#000000;}
A.r3:hover {font-size:12px;text-decoration:underline;color:#ff0000;}
.bd{ background:#03F}
--
/style
/head
body
%
dim filename
dim biaoname
filename="message.asp"
biaoname="message"
%
center
table width="784" height="45" border="0" align="center"
tr
td width="386" height="41" align=right留言-管理/td
td width="382"nbsp;/td
/tr
tr
td width="386" height="41" align=rightnbsp;/td
td width="382"nbsp;/td
/tr
/table
%
if request("action")="" then '显示信息
%
TABLE width="393" border="0" cellpadding="4" cellspacing="1" bgcolor="#ffffff" align="center"
tr height=20 bgcolor="BEBFD9"
TD width="46" height="20" align="center" class=bdfont color="#FFFFFF"b编号/b/font/TD
TD width="63" align="center" class=bdfont color="#FFFFFF"b留言时间/b/font/TD
TD width="98" align="center" class=bdfont color="#FFFFFF"b内容/b/font/TD
TD width="59" align="center" class=bdfont color="#FFFFFF"b回复/b/font/TD
TD width="59" align="center" class=bdfont color="#FFFFFF"
input type='submit' value='删除'
/font/TD
/TR
%
dim strsql
set rs=server.createobject("adodb.recordset")
strsql="select * from "biaoname" order by Id desc"
rs.open strsql,Conn,3,2
if rs.eof then
response.write("div style=width:500px;height:500px;text-align:center没有信息/div")
else
'response.write("div style=width:500px;height:500px;")
PERPAGE=15
if request("pageno")="" or isNumeric(request("pageno"))=0 or request("pageno")"1" then
curpage = 1
else
curpage = cint(request("pageno"))
end if
rs.pagesize = PERPAGE
if curpagers.pagecount then curpage=rs.pagecount
rs.absolutepage = curpage
%
%
for i=1 to rs.pagesize
if rs.eof then
exit for
end if
%
tr height=20 %if i mod 2 = 0 then
response.write("bgcolor=#cccccc")
else
response.write("bgcolor=#EEEeee")
End if
%
TD height="27" align="center" font color="#000000"b%=rs("id")%/b/font/TD
TD align="center" font color="#000000"b%=rs("time1")%/b/font/TD
TD align="center" font color="#000000"b%=rs("memo")%/b/font/TD
TD align="center" a href=?action=huiid=%=rs("id")%点击回复/a/TD
TD align="center" a href=?action=delid=%=rs("id")%删除/a/TD
/TR
%if rs("hui")"" then%
tr height=20 bgcolor="#eeeeee"
TD width="46" height="27" align="center" 回复:/TD
TD colspan="4" align="left" nbsp;
%=rs("hui")%
/TD
/TR
%End if%
%
rs.movenext
next
%
/TABLE
% if curpage = 1 then
response.write "br/div style=width:500px;height:30px;text-align:center 首页 | 上一页 | "
else
response.write "br/div style=width:500px;height:30px;text-align:centera href='?pageno=1'首页/a | a href='?pageno="curpage-1"typeid="request("typeid")"'上一页/a | "
end if
if curpage = rs.pagecount then
response.write "下一页 | 尾页/div"
else
response.write "a href='?pageno="curpage+1"leixing="leixing"'下一页/a | a href='?pageno="rs.pagecount"typeid="request("typeid")"'尾页/a/div"
end if
rs.close
end if
end if
'--------------------------------------------------------------修改完成----------------
if request("action")="del" then '删除
id=request("id")
set rs=server.createobject("adodb.recordset")
sql="SELECT * from "biaoname" where id="cstr(id)
rs.open sql,conn,1,3
rs.delete
'rs.update
response.Write "scriptalert('删除成功!');this.location.href='"filename"';/SCRIPT"
end if
if request("action")="hui" then '回复
%
form action="?action=huisave" method="post"
table width="454" border="0" cellspacing="0" cellpadding="0"
tr
td width="52" height="168"回复:/td
td width="402"label
textarea name="hui" id="textarea" cols="45" rows="5"/textarea
/label
input type="hidden" name="id" value="%=request("id")%"
/td
/tr
tr
td height="59"nbsp;/td
tdlabel
input type="submit" name="button" id="button" value="提交"
/label/td
/tr
/table
/form
%End if
if request("action")="huisave" then '删除
if request("hui")="" then
response.write ("scriptwindow.alert('回复内容不能为空!');this.location.href='message.asp'/script")
response.end
End if
set rs1=server.CreateObject("ADODB.RecordSet")
sql="SELECT * from "biaoname" where id="request("id")
rs1.open sql,conn,3,2
rs1("hui")=request("hui")
rs1.update
rs1.close
response.write ("scriptwindow.alert('回复成功!');this.location.href='message.asp'/script")
End if
%
/center
/body
/html
运行调式程序
打开一个IE浏览器
输入:
地址
就可以进入到留言板界面,进行留言了
点击左边的留言管理,就可以进入留言管理界面,在留言管理界面可以回复和删除留言信息。
ASP留言板问题
留言板一般都是用textarea/textarea这个控件弄的,只要在其中设置一下就可以了,例如: textarea wrap=hard name=comment2 rows=5 cols=25 /textarea
其中wrap的属性分别表示为: hard ----“硬换行”,好象 MS-WORD 里的“硬回车”。 相当于自动换行
soft ---- “软换行”,好象 MS-WORD 里的“软回车”。
off ---- 不换行,是缺省设置。
楼主想要的效果是"硬换行"
楼主只要在输入留言的这个表单中textarea/textarea,多加个wrap=hard设置就行了,ok?
ASP编写的留言板是干什么用的?
一、留言板是放在网页上,让浏览者发表言论的
二、留言板都是由用户写,然后可以单独给站长看(留言时,用户选中“悄悄话”就可以),也可以给任何一个人看(默认情况下就是这样的)
三、使用asp完全可以实现你的要求!!!
到网络上搜索“asp留言板 源代码 下载”,上传到自己的网络空间即可使用
asp留言板的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于asp留言板 提示部分参数未填写、asp留言板的信息别忘了在本站进行查找喔。
标签:asp留言板