140 likes | 232 Views
資料庫、 Frame 應用→留言板設計. main.htm. <title> 讀者交流 </title> <FRAMESET Rows="110,*" border=0> <FRAME NAME="top" NORESIZE SRC="menu.htm"> <FRAME NAME="down" NORESIZE SRC="title.htm"> </FRAMESET> </HTML>. title.htm. <Center> <img src="title.jpg"> </Center>. menu.htm.
E N D
資料庫、Frame應用→留言板設計 main.htm <title>讀者交流</title> <FRAMESET Rows="110,*" border=0> <FRAME NAME="top" NORESIZE SRC="menu.htm"> <FRAME NAME="down" NORESIZE SRC="title.htm"> </FRAMESET> </HTML> title.htm <Center> <img src="title.jpg"> </Center>
menu.htm <TITLE>復文書局的書局簡介</TITLE><a name="start"></a> <body bgcolor=black LINK=blue VLINK=blue ALINK=blue> <B><font color=red>高雄復文圖書出版社、麗文文化事業股份有限 公司 傳真:(07)226-4697<br> <font color=yellow>地址︰高雄市泉州街5號 電話:(07)226-1273、 226-5267</font><p></B> <CENTER><A HREF="NewForm.htm" target="down">新增留言</A> | <A HREF="ListPS.asp" target="down">留言列表</A> | <A HREF="main.htm" target="_top">返回進站畫面</A>
<BODY BGCOLOR=PINK> <title>讀者交流--新增留言</title> <CENTER><FONT size=5 color=BLUE> <B>新增留言</B></FONT></CENTER> <form method=post action=NewPS.asp name='Main'> <table BORDER="3" WIDTH="550" bgcolor="yellow" align="center"> <TR> <TD><FONT SIZE=4 color=blue>作者:</FONT> <INPUT TYPE="TEXT" NAME="AUTHOR" SIZE="45" MAXLENGTH="20"></TD> </TR> <TR> <TD><FONT SIZE=4 color=blue>標題:</FONT> <INPUT TYPE="TEXT" NAME="TITLE" SIZE="45" MAXLENGTH="40"></TD> </TR> <TR> <TD><FONT SIZE=4 color=blue>留言內容:</FONT></TD> </TR> <TR> <TD><TEXTAREA COLS='60' ROWS='6' NAME='CONTENT'></TEXTAREA></TD> </TR></table><BR><CENTER> <input TYPE="SUBMIT" NAME="state" VALUE="送出留言"> <input TYPE="RESET" VALUE="清除重寫"> <input TYPE="BUTTON" VALUE="返回上頁" onclick="history.back()"></CENTER> </form> NewForm.htm
<% PSAuthor=Request("Author"): PSTitle=Request("Title") PSContent=Request("Content"): PSContent=Replace(PSContent, vbCrLf,"<br>") '換行 PSTime=date '開啟資料庫 Set connection= Server.CreateObject("ADODB.Connection") connection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("fuwen.mdb") '開啟資料表格,決定此留言之編號 Set rs= connection.execute("Board"): PSNo=1 Do while not rs.eof PSNo=PSNo+1: rs.movenext Loop '下SQL指令,新增資料 SQLcmd = "insert into Board values('"& PSNo & "','" & PSAuthor & "','" & PSTitle &"','" &_ PSContent & "','" & PSTime& "')" connection.execute(SQLcmd) %> <script Language="JavaScript">alert("此留言資料已經存檔!")</script> <% '自動跳頁 response.write "<META HTTP-EQUIV='Refresh' CONTENT='0;URL=ListPS.asp'>" %> NewPS.asp
Access ODBC參數設定︰ (p.306) connection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" &_ Server.MapPath("fuwen.mdb") 可改為 DSN(Data Source Name)設定法︰ connection.Open "fuwen"
下SQL指令,新增資料 Set connection= Server.CreateObject("ADODB.Connection") connection.Open "fuwen" SQLcmd = "insert into Board values('"& PSNo & "','" & PSAuthor & "','" & PSTitle &"','" &_ PSContent & "','" & PSTime& "')" connection.execute(SQLcmd) =另一種使用資料錄之做法 Set connection= Server.CreateObject("ADODB.Connection") connection.Open "fuwen" Set rs= Server.CreateObject("ADODB.Recordset") rs.Open "Board", connection, 3, 3 rs.AddNew rs("PSNo")=PSNo: rs("PSAuthor")=PSAuthor rs("PSTitle")=PSTitle: rs("PSTime")=PSTime : rs("PSContent")=PSContent rs.Update
<title>讀者交流--全部留言列表</title> <BODY BGCOLOR="#000000" TEXT="DFDFDF" LINK="12AFFF" VLINK="129F9F"> <CENTER><FONT size=5 color=pink><B>全部留言列表</B></FONT><BR><BR> <% Set connection= Server.CreateObject("ADODB.Connection") connection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("fuwen.mdb") Set rs= connection.execute("Board") %> <TABLE align="Center" border="0" cellspacing="0" WIDTH="550"> <TR BGCOLOR="Orange"> <TD><font color=blue>篇號 </TD><TD><font color=blue>作者 </TD> <TD><font color=blue>留言日期 </TD><TD><font color=blue>留言標題</TD> </TR> <% do while not rs.eof HyperLink="SeePS.asp?No=" & rs("PSno") response.write "<TR><TD>" & rs("PSno") & "</TD><TD>" & rs("PSauthor") &_ "</TD><TD>" & rs("PStime") & "</TD><TD><A HREF='" & HyperLink & "'>" &_ rs("PStitle") & "</A> </TD></TR>" rs.movenext loop %> <TR> <td colspan="4"><HR></td></TR> </TABLE></center> ListPS.asp
<title>讀者交流--查詢留言</title> <BODY BGCOLOR="#000000" TEXT="DFDFDF" LINK="12AFFF" VLINK="129F9F"> <CENTER><FONT size=5 color=pink><B>查詢留言</B></FONT><BR><BR> <% PSno=Request.querystring("No") Set connection= Server.CreateObject("ADODB.Connection") connection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath("fuwen.mdb") Set rs= connection.execute("Select * From Board Where PSno=" & PSno) %> <TABLE align="Center" border="0" cellspacing="0" WIDTH="550"> <TR><TD bgcolor="Orange"><FONT color=BLUE>留言內容</FONT></TD></TR> <TR><TD> <pre> <FONT size=4>編號: <% =rs("PSno") %> 作者: <% =rs("PSauthor") %> 日期: <% =rs("PStime") %> 標題: <% =rs("PStitle") %><BR><BR> <% =rs("PScontent") %> </pre> </TD></TR> <TR><TD> <HR></TD></TR> </TABLE> <br></CENTER> SeePS.asp