asphalt(asp留言板)
很多人对asphalt,asp留言板不是很了解那具体是什么情况呢,现在让我们一起来瞧瞧吧!
1、当您开始构建数据库时,我们会创建一个新的数据库,进入企业管理器,右键单击该数据库,然后选择new database。
2、输入数据库名称。
3、选择新的数据库,在右边的窗口中点击右键,在弹出的菜单中选择新建数据表。
4、表名:消息
5、ID int 4
6、备忘录文本16
7、时间1 nvarchar 50
8、慧文16
9、Id自动递增1。
10、备忘录是消息内容。
11、1次消息时间
12、惠回复内容
13、添加,4个字段
14、然后设置ID字段自动加1,如下图所示
15、创建一个新站点,并将其命名为message。
16、在D盘新建一个文件夹,命名为message board,放IIS的物理路径(参考aspIIS设置的文章)
17、http://jingyan . Baidu.com/article/fedf 0737663 b 3935 AC 8977 fa . html
18、)设置为D:\\留言板
19、将站点的文件路径设置为D:\\留言板。
20、在Adobe Dreamweaver CS4中创建新文件
21、单击以创建html文档。
22、然后修改本文档的代码,将代码改为GB2312。
23、然后删除文件中的默认代码,并重新输入以下新代码。
24、以下代码连接到sql2000数据库。
25、%
26、Dim数据库
27、Database=\'datamessage \'
28、昏暗的康恩,康恩斯特
29、设置conn=服务器。CreateObject(\'ADODB。连接’)
30、ConnStr=\' Provider=sqloledbServer=localhostdatabase=\' Databaseuid=sapwd=\'
31、打开连接
32、%
33、然后将其保存为conn.asp文件。
34、请注意,保存文件的类型是所有文件(*。*).
35、再次创建一个名为default.asp的新文件,这是用于显示和添加消息的页面。
36、编码也需要改成GB2312。
37、此处输入的代码如下:
38、!- #include file=\'conn.asp\' -
39、%
40、if request(\' action \')=\' addmessagesave \'然后
41、如果trim(request(\'memo\'))=\' \',则
42、response . write(\' script language=JavaScript alert(\'消息内容不能为空!\');location=\'message.asp\'/script \')
43、回应。结束()
44、如果…就会结束
45、设置rsa=Server。CreateObject(\'ADODB。记录集’)
46、strsqla=\'select * from [message]\'
47、康涅狄格州,3,2
48、rsa.addnew
49、rsa(\'备忘录\')=请求(\'备忘录\')
50、RSA(\' time 1 \')=现在
51、rsa.update
52、response . write(\' script language=JavaScript alert(\'消息成功!\');location=\'message.asp\'/script \')
53、回应。结束()
54、如果…就会结束
55、%
56、!\' DOCTYPE html PUBLIC \'-//W3C//DTD XHTML 1.0 Transitional//EN \' \' http://www . w3 . org/TR/XHTML 1/DTD/XHTML 1-Transitional . DTD \'
57、html xmlns=\' http://www . w3 . org/1999/XHTML \'
58、头
59、meta http-equiv=\' Content-Type \' Content=\' text/html;charset=gb2312\' /
60、标题在线消息/标题
61、风格
62、* { margin:0pxpadding:0pxfont-size :14 px;color: # 000000}
63、a { font-size :14 px;color: # 999999}
64、车身{margin:0 au
65、</style>
66、</head>
67、<body>
68、<table width=\"930\" height=\"553\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" >
69、 <tr>
70、 <td width=\"230\" valign=\"top\" align=\"center\">
71、<br/><br/><br/>
72、<a href=\"manage.asp\">留言管理</a>
73、<br/><br/>
74、
75、</td>
76、 <td width=\"700\" height=\"553\" valign=\"top\" align=left>
77、 留言<div class=height9></div>
78、 <br/><br/>
79、 <br/>
80、 <%
81、 message
82、
83、addmessage
84、
85、
86、
87、 %>
88、</td>
89、 </tr>
90、</table>
91、</body>
92、</html>
93、<%
94、sub addmessage()
95、%>
96、<form id=\"form1\" name=\"form1\" method=\"post\" action=\"?action=addmessagesave\">
97、<table width=\"519\" height=\"200\" border=\"0\">
98、 <tr>
99、 <td width=\"94\" height=\"55\"> </td>
100、 <td width=\"415\">
101、 <input type=\"hidden\" name=\"dd\" value=\"0\" checked=\"checked\"/> </td>
102、 </tr>
103、 <tr>
104、 <td height=\"104\" align=center>内容:</td>
105、 <td><label>
106、 <textarea name=\"memo\" cols=\"50\" rows=\"6\" ></textarea>
107、 </label></td>
108、 </tr>
109、 <tr>
110、 <td height=\"33\"> </td>
111、 <td>
112、
113、 <input type=\"submit\" name=\"Submit\" value=\"提交\" /> </td>
114、 </tr>
115、</table>
116、</form>
117、<%
118、end sub
119、SUB message()
120、set rs=Server.CreateObject(\"ADODB.RecordSet\")
121、sql=\"select * from message order by id desc\"
122、rs.open sql,conn,1,1
123、
124、
125、if rs.eof then
126、
127、
128、
129、if request(\"key\")<>\"\" then
130、response.write(\"<div style=\"\"text-align:center\"\">没有查到您要查找的留言!</div>\")
131、else
132、response.write(\"<div style=width:500px;height:50px;text-align:center>暂时没有留言留言!</div>\")
133、End if
134、else
135、response.write(\"<div >\")
136、PERPAGE=10
137、if request(\"pageno\")=\"\" or isNumeric(request(\"pageno\"))=0 or request(\"pageno\")<\"1\" then
138、curpage = 1
139、else
140、curpage = cint(request(\"pageno\"))
141、end if
142、
143、rs.pagesize = PERPAGE
144、if curpage>rs.pagecount then curpage=rs.pagecount
145、rs.absolutepage = curpage
146、for i=1 to rs.pagesize
147、if rs.eof then
148、exit for
149、end if
150、%>
151、
152、<table width=\"553\" height=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=#ffffff style=\"border:1px solid #cccccc;margin-left:10px;margin-top:5px;\">
153、<tr>
154、 <td style=\"padding-left:20px;\">[内容]</td>
155、 <td class=\"xb-a04\"><%=rs(\"memo\")%></td>
156、 <td> </td>
157、 </tr>
158、<tr>
159、 <td height=\"31\" style=\"padding-left:20px;\"></td>
160、 <td class=\"xb-a04\"><%
161、
162、
163、%></td>
164、 <td>[时间:<%=rs(\"time1\")%>]</td>
165、 </tr>
166、<%if rs(\"hui\")<>\"\" then%>
167、<tr>
168、 <td style=\"padding-left:20px;\">[回复]</td>
169、 <td colspan=\"2\" class=\"xb-a04\" align=\"left\"> <%=rs(\"hui\")%></td>
170、 </tr>
171、 <%End if%>
172、
173、</table>
174、<%
175、rs.movenext
176、next
177、
178、if curpage = 1 then
179、response.write \"</div><BR><div style=width:440px;height:30px;text-align:center> 首页 | 上一页 | \"
180、else
181、response.write \"</div><BR><div style=width:440px;height:30px;text-align:center; ><a href=\'?pageno=1\'>首页</a> | <a href=\'?pageno=\"&curpage-1&\"&leixing=\"&leixing&\"\'>上一页</a> | \"
182、end if
183、if curpage = rs.pagecount then
184、response.write \"下一页 | 尾页</div>\"
185、else
186、response.write \"<a href=\'?pageno=\"&curpage+1&\"&leixing=\"&leixing&\"\'>下一页</a> | <a href=\'?pageno=\"&rs.pagecount&\"&leixing=\"&leixing&\"\'>尾页</a></div>\"
187、end if
188、
189、rs.close
190、end if
191、End sub
192、%>
193、新建一个管理留言的页面,名为manage.asp
194、同样先改编码为GB2312去掉原来的代码重新输入新的代码如下:
195、<!--#include file=\"conn.asp\"-->
196、<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
197、<html>
198、<head>
199、<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">
200、<title>无标题文档</title>
201、<style type=\"text/css\">
202、<!--
203、body {font-size: 12px; color: #000000; font-family: 宋体}
204、td {font-size: 12px; color: #000000; font-family: 宋体;}
205、.t1 {font:12px 宋体;color=000000}
206、.t2 {font:12px 宋体;color:ffffff}
207、.bt1 {font:14px 宋体;color=000000}
208、.bt2 {font:14px 宋体;color:ffffff}
209、A:link {color: #000066}
210、A:visited {color: #000066}
211、A:hover {color: #ff0000}
212、A.r1:link {font-size:12px;text-decoration:underline;color:#000000;}
213、A.r1:visited {font-size:12px;text-decoration:underline;color:#000000;}
214、A.r1:hover {font-size:12px;text-decoration:underline;color:#ff0000;}
215、A.r2:link {font-size:12px;text-decoration:underline;color:#ffffff;}
216、A.r2:visited {font-size:12px;text-decoration:underline;color:#ffffff;}
217、A.r2:hover {font-size:12px;text-decoration:underline;color:#ff6600;}
218、A.r3:link {font-size:12px;text-decoration:none;color:#000000;}
219、A.r3:visited {font-size:12px;text-decoration:none;color:#000000;}
220、A.r3:hover {font-size:12px;text-decoration:underline;color:#ff0000;}
221、.bd{ background:#03F}
222、-->
223、</style>
224、</head>
225、<body>
226、<%
227、dim filename
228、dim biaoname
229、filename=\"message.asp\"
230、biaoname=\"message\"
231、%>
232、<center>
233、<table width=\"784\" height=\"45\" border=\"0\" align=\"center\">
234、 <tr>
235、 <td width=\"386\" height=\"41\" align=right>留言-管理</td>
236、 <td width=\"382\"> </td>
237、 </tr>
238、 <tr>
239、 <td width=\"386\" height=\"41\" align=right> </td>
240、 <td width=\"382\"> </td>
241、 </tr>
242、</table>
243、<%
244、if request(\"action\")=\"\" then \'显示信息
245、%>
246、<TABLE width=\"393\" border=\"0\" cellpadding=\"4\" cellspacing=\"1\" bgcolor=\"#ffffff\" align=\"center\">
247、 <tr height=20 bgcolor=\"BEBFD9\">
248、 <TD width=\"46\" height=\"20\" align=\"center\" class=bd><font color=\"#FFFFFF\"><b>编号</b></font></TD>
249、 <TD width=\"63\" align=\"center\" class=bd><font color=\"#FFFFFF\"><b>留言时间</b></font></TD>
250、 <TD width=\"98\" align=\"center\" class=bd><font color=\"#FFFFFF\"><b>内容</b></font></TD>
251、 <TD width=\"59\" align=\"center\" class=bd><font color=\"#FFFFFF\"><b>回复</b></font></TD>
252、 <TD width=\"59\" align=\"center\" class=bd><font color=\"#FFFFFF\">
253、 <input type=\'submit\' value=\'删除\'>
254、 </font></TD>
255、 </TR>
256、<%
257、dim strsql
258、set rs=server.createobject(\"adodb.recordset\")
259、strsql=\"select * from \"&biaoname&\" order by Id desc\"
260、rs.open strsql,Conn,3,2
261、 if rs.eof then
262、response.write(\"<div style=width:500px;height:500px;text-align:center>没有信息</div>\")
263、else
264、\'response.write(\"<div style=width:500px;height:500px;>\")
265、PERPAGE=15
266、if request(\"pageno\")=\"\" or isNumeric(request(\"pageno\"))=0 or request(\"pageno\")<\"1\" then
267、curpage = 1
268、else
269、curpage = cint(request(\"pageno\"))
270、end if
271、
272、rs.pagesize = PERPAGE
273、if curpage>rs.pagecount then curpage=rs.pagecount
274、rs.absolutepage = curpage
275、
276、%>
277、
278、<%
279、for i=1 to rs.pagesize
280、if rs.eof then
281、exit for
282、end if
283、%>
284、
285、<tr height=20 <%if i mod 2 = 0 then
286、
287、response.write(\"bgcolor=#cccccc\")
288、else
289、response.write(\"bgcolor=#EEEeee\")
290、End if
291、%>>
292、<TD height=\"27\" align=\"center\" ><font color=\"#000000\"><b><%=rs(\"id\")%></b></font></TD>
293、<TD align=\"center\" ><font color=\"#000000\"><b><%=rs(\"time1\")%></b></font></TD>
294、<TD align=\"center\" ><font color=\"#000000\"><b><%=rs(\"memo\")%></b></font></TD>
295、<TD align=\"center\" ><a href=?action=hui&id=<%=rs(\"id\")%>>点击回复</a></TD>
296、<TD align=\"center\" ><a href=?action=del&id=<%=rs(\"id\")%>>删除</a></TD>
297、 </TR>
298、 <%if rs(\"hui\")<>\"\" then%>
299、<tr height=20 bgcolor=\"#eeeeee\" >
300、<TD width=\"46\" height=\"27\" align=\"center\" >回复:</TD>
301、<TD colspan=\"4\" align=\"left\" >
302、
303、
304、 <%=rs(\"hui\")%>
305、
306、 </TD>
307、 </TR>
308、<%End if%>
309、
310、<%
311、rs.movenext
312、next
313、%>
314、</TABLE>
315、<%if curpage = 1 then
316、response.write \"<br/><div style=width:500px;height:30px;text-align:center> 首页 | 上一页 | \"
317、else
318、response.write \"<br/><div style=width:500px;height:30px;text-align:center><a href=\'?pageno=1\'>首页</a> | <a href=\'?pageno=\"&curpage-1&\"&typeid=\"&request(\"typeid\")&\"\'>上一页</a> | \"
319、end if
320、
321、if curpage = rs.pagecount then
322、response.write \"下一页 | 尾页</div>\"
323、else
324、response.write \"<a href=\'?pageno=\"&curpage+1&\"&leixing=\"&leixing&\"\'>下一页</a> | <a href=\'?pageno=\"&rs.pagecount&\"&typeid=\"&request(\"typeid\")&\"\'>尾页</a></div>\"
325、end if
326、rs.close
327、end if
328、end if
329、\'--------------------------------------------------------------修改完成----------------
330、if request(\"action\")=\"del\" then \'删除
331、id=request(\"id\")
332、set rs=server.createobject(\"adodb.recordset\")
333、sql=\"SELECT * from \"&biaoname&\" where id=\"&cstr(id)
334、rs.open sql,conn,1,3
335、rs.delete
336、\'rs.update
337、response.Write \"<script>alert(\'删除成功!\');this.location.href=\'\"&filename&\"\';</SCRIPT>\"
338、end if
339、if request(\"action\")=\"hui\" then \'回复
340、%>
341、<form action=\"?action=huisave\" method=\"post\">
342、<table width=\"454\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
343、 <tr>
344、 <td width=\"52\" height=\"168\">回复:</td>
345、 <td width=\"402\"><label>
346、 <textarea name=\"hui\" id=\"textarea\" cols=\"45\" rows=\"5\"></textarea>
347、 </label>
348、 <input type=\"hidden\" name=\"id\" value=\"<%=request(\"id\")%>\">
349、 </td>
350、 </tr>
351、 <tr>
352、 <td height=\"59\"> </td>
353、 <td><label>
354、 <input type=\"submit\" name=\"button\" id=\"button\" value=\"提交\">
355、 </label></td>
356、 </tr>
357、</table>
358、</form>
359、<%End if
360、if request(\"action\")=\"huisave\" then \'删除
361、if request(\"hui\")=\"\" then
362、response.write (\"<script>window.alert(\'回复内容不能为空!\');this.location.href=\'message.asp\'</script>\")
363、response.end
364、End if
365、set rs1=server.CreateObject(\"ADODB.RecordSet\")
366、sql=\"SELECT * from \"&biaoname&\" where id=\"&request(\"id\")
367、rs1.open sql,conn,3,2
368、rs1(\"hui\")=request(\"hui\")
369、rs1.update
370、rs1.close
371、response.write (\"<script>window.alert(\'回复成功!\');this.location.href=\'message.asp\'</script>\")
372、End if
373、%>
374、</center>
375、</body>
376、</html>
377、运行调式程序
378、打开一个IE浏览器
379、输入:http://localhost/
380、地址
381、就可以进入到留言板界面,进行留言了
382、点击左边的留言管理,就可以进入留言管理界面,在留言管理界面可以回复和删除留言信息。
本文【asphalt(asp留言板)】到此讲解完毕了,希望对大家有帮助。