2013年7月1日 星期一

留言板(ASP)

talk.htm
< script language="javascript" > 
< !--  
function check()  
{  
project=document.myform.project.value;  
word=document.myform.word.value;  
if(project=="")  
{  
alert("沒有輸入主題!"); 
return;  
}  
else  
{  
if(word=="")  
{  
alert("沒有任何留言!"); 
return;  
}  
}  
document.myform.submit();  
}
 -- > 
< /script >

< html > 
< head >< title >留言板< /title >< /head >

< body background="../pic/bg.gif" vlink="#0000FF" >
< form action="../asp/tform.asp" Method=post name="myform" > 
< div align="left" >
< div align="center" > 
< center >  
< table border="1" width="634" height="1" bordercolor="#008000" >  
< tr >  
< td width="607" align="right" height="4" valign="top" colspan="2" > 
< p align="center" >
< font color="#0000FF" >& nbsp;& nbsp;& nbsp;& nbsp;< font size="5" >  < /font > < /font >
< font color="#000000" >< font size="5" >< b >留& nbsp;& nbsp;& nbsp;  言& nbsp;& nbsp;& nbsp; 板< /b >< /font >& nbsp;< /font >
< font color="#0000FF" >& nbsp;& nbsp;< /font >< font color="#0000FF" >  & nbsp;< /font >
< /p >  
< /td >  
< /tr >  
< tr >  
< td width="119" align="right" height="1" valign="top" >姓名:< /td >  
< td width="231" height="1" >< input type="text" name="name" size="27" tabindex="1" >
< font size="2" >& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;
< font color="#FF0000" >& nbsp;< /font >
< /font >
< /td >  
< /tr >  
< tr >  
< td width="119" align="right" height="1" valign="top" >旅遊地點:< /td >  
< td width="500" height="1" >< input type="text" name="address" size="27" tabindex="2" >< /td >  
< /tr >  
< tr >  
< td width="119" align="right" height="1" valign="top" >主題:< /td >  
< td width="500" height="1" >< input type="text" name="project" size="33" tabindex="3" >< /td >  
< /tr >  
< tr >  
< td width="119" align="right" height="16" valign="top" >  < p align="right" >留言:< /p >  < /td >  
< td width="500" height="16" >
< font size="2" >
< textarea rows="6" name="word" cols="68" tabindex="4" >< /textarea >
< /font >
< /td >  
< /tr >  
< tr >  
< td width="119" align="right" height="87" valign="top" >心情圖示:< /td >  
< td width="500" height="87" valign="top" align="right" nowrap >  
< p align="left" >  
< font size="2" >  
< input type="radio" value="../pic/person1.gif" name="person" tabindex="5" >
< img border="0" src="../pic/person1.gif" width="50" height="61" >& nbsp;& nbsp;& nbsp;& nbsp;& nbsp; 
< input type="radio" value="../pic/person2.gif" name="person" tabindex="5" >
< img border="0" src="../pic/person2.gif" width="48" height="62" >& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;  
< input type="radio" value="../pic/person3.gif" name="person" tabindex="5" >
< img border="0" src="../pic/person3.gif" width="49" height="62" >& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;  
< input type="radio" value="../pic/person4.gif" name="person" tabindex="5" >& nbsp;& nbsp;
< img border="0" src="../pic/person4.gif" width="44" height="61" >
< br >  
< input type="radio" value="../pic/person5.gif" name="person" tabindex="5" >& nbsp;& nbsp;
< img border="0" src="../pic/person5.gif" width="53" height="59" >& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;  
< input type="radio" value="../pic/person6.gif" name="person" tabindex="5" >& nbsp;& nbsp;
< img border="0" src="../pic/person6.gif" width="51" height="59" >& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;  
< input type="radio" value="../pic/person7.gif" name="person" tabindex="5" >& nbsp;& nbsp;
< img border="0" src="../pic/person7.gif" width="42" height="56" >  & nbsp;& nbsp;& nbsp;& nbsp;& nbsp;
< input type="radio" value="no" name="person" tabindex="5" checked >
< /font >
< font color="#FF0000" >不選擇< /font >
< font size="2" >& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;< /font >
< /p >  
< /td >  
< /tr >  
< /table >  
< /center >  
< /div >
< /div > 
< p align="center" > 
< input type="button" value="留言" tabindex="6" onclick="check()" >
< font size="2" >& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp; & nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp; < /font >
< a href="../asp/tbook.asp" target="_self" >觀看留言板< font size="2" >& nbsp;< /font >< /a >
< font size="2" >& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp; < /font >
< input type="reset" value="清除" name="reset" tabindex="7" >
< /p >  
< /form >  
< /body >                                              
< /html >

< html >
< head >< title >留言板< /title >< /head >
< body background="../pic/bg.GIF" vlink="#0000FF" > 
< /html >

tbook.asp
< HTML >
< HEAD >< TITLE >留言板< /TITLE >< /HEAD >
< BODY background="../pic/bg.gif" vlink="#0000FF" >
< H2 ALIGN=CENTER >
< b >留& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;言& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;板< /b >
< img border="0" src="../pic/acdrule.gif" width="100%" height="10" >
< /H3 >
< % 
SQL = "Select * From tbook Order By time DESC" 
Set conn = Server.CreateObject("ADODB.Connection") 
DBPath =Server.MapPath("../db/free.mdb") 
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" &DBPath 
SET rs =Server.CreateObject("ADODB.Recordset") 
rs.open sql,conn,3,2 
If rs.BOF=True Then 
Response.Write "< h2 >< p align=center >抱歉目前無資料!< /p >< /h2 >" 
Response.Write "< p align=center >< a href=""javascript:history.back()"" >返回上一頁< /a >< /p >"
Response.End 
End If 
Page = CLng(Request("Page")) rs.PageSize=5 
If Page <  1 Then Page = 1 
If Page  > rs.PageCount Then Page = rs.PageCount 
ShowOnePage rs, Page
% >
< DIV ALIGN=right >
< A HREF="../html/talk.htm" >開始留言< /A >
< A HREF="../index.htm" >回首頁< /A > 
< %  
If Page <  > 1 Then Response.Write "< A HREF=tbook.asp?Page=1 >第一頁< /A > " 
Response.Write "< A HREF=tbook.asp?Page=" & (Page-1) & " >上一頁< /A > " 
End If 
If Page <  > rs.PageCount Then Response.Write "< A HREF=tbook.asp?Page=" & (Page+1) & " >下一頁< /A > " 
Response.Write "< A HREF=tbook.asp?Page=" & rs.PageCount & " >最後一頁< /A > " 
End If
% >
頁次:< FONT COLOR="Red" >< %=Page% >/< %=rs.PageCount% >< /FONT >
< /BODY >
< /HTML >
< %  
Sub ShowOnePage( rs, Page ) 
rs.AbsolutePage = Page 
For iPage = 1 To rs.PageSize 
RsToTbook rs rs.MoveNext 
If rs.EOF Then Exit For 
Next 
End Sub  
Sub RsToTbook( rs ) 
word=Replace(rs("word"), vbCrLf, "< BR >" ) 
If Len(rs("pic")) <  > 0 Then PicHTML = "< IMG SRC=" & rs("pic") & " >" 
Else PicHTML = "" 
End If
% >
< p align=left >
< TABLE BOBDER=0 WIDTH=640 > 
< TR >< TD WIDTH=60 >< %=PicHTML% >< /TD > 
< TD width=200 > 
< table bobder=0 align=left > 
< TR > < td >主 題:& nbsp;< %=rs("project")% >< /TD > < /TR > 
< TR > < TD >姓名:& nbsp;< %=rs("name")% >< /TD > < /TR > 
< TR > < td >時 間:< %=rs("time")% >< /TD > < /TR > 
< /table > 
< /TD > 
< TD width=380 BGCOLOR=#00FFFF valign="top" align=left >< %=word% >< /TD >  
< /TR >
< /TABLE >
< img border="0" src="../pic/acdrule.gif" width="100%" height="10" >
< % 
End Sub
% >

沒有留言:

張貼留言