W
wxhn
Unregistered / Unconfirmed
GUEST, unregistred user!
个人主页留言薄的制作
*文件名:book.htm
<html>
<head>
<title>留言薄</title>
</head>
<body bgcolor="#BED9FC"
background="images/bg.gif">
<p align="center"><img src="images/gbook.gif"
alt="GBook.gif (12142 bytes)"
WIDTH="374"HEIGHT="83"> </p>
<p align="center">[<a href="disp.asp">我要看留言板</a>]&nbsp;
[<a href="../index.asp">返回首页</a>]</p>
<form method="POST"
action="book.asp">
<input type="hidden"
name="task"
value="insert"><div align="left"><table>
<tr>
<td align="right">姓名</td>
<td><img src="images/bottom-b.gif"
alt="BUTTOM-B.GIF (179 bytes)"
WIDTH="16"
HEIGHT="16"></td>
<td><input name="name"
size="46"></td>
</tr>
<tr>
<td align="right">性别</td>
<td><img src="images/bottom-g.gif"
alt="BUTTOM-G.GIF (179 bytes)"
WIDTH="16"
HEIGHT="16"></td>
<td><input name="sex"
size="46"></td>
</tr>
<tr>
<td align="right">来自</td>
<td><img src="images/bottom-b.gif"
alt="BUTTOM-B.GIF (179 bytes)"
WIDTH="16"
HEIGHT="16"></td>
<td><input name="from"
size="46"></td>
</tr>
<tr>
<td align="right">主页URL</td>
<td><img src="images/homepage.gif"
alt="HomePage.gif (1232 bytes)"
WIDTH="30"
HEIGHT="30"></td>
<td><input name="url"
size="46"></td>
</tr>
<tr>
<td align="right">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
E-mail</td>
<td><img src="images/email.gif"
alt="Email.gif (1197 bytes)"
WIDTH="30"
HEIGHT="30"></td>
<td><input name="email"
size="46"></td>
</tr>
<tr>
<td align="right">留言</td>
<td colspan="2"><textarea wrap="off"
name="comments"
cols="49"
rows="9"></textarea></td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td colspan="2"><dl>
<dd align="center">&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit"
value="我写好了">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset"
value="重新再写"></dd>
</dl>
</td>
</tr>
</table>
</div>
</form>
<p align="center"> </p>
</body>
</html>
*book.asp
<% @language="vbscript"
%>
<%
if Request.ServerVariables("REQUEST_METHOD"="POST"
then
set fsFilesys=CreateObject("Scripting.FileSystemObject"
‘打开文本文件server.mappath("/"是返回服务器发行目录的真实路径,也就是比如说:c:/Inetpub/wwwroot这个路径,
然后"/realchat/book/book.txt"就是相对于这个路径基础上的路径。
set myText=fsFilesys.OpenTextFile(Server.MapPath("/"&"/realchat/book/book.txt"
Temp=myText.Readall
myText.Close
if Request("task"="insert"
then
Tname=request.form("name"
Tsex=request.form("sex"
Temail=request.form("email"
turl=request.form("url"
Tfrom=request.form("from"
Tcomments=request.form("comments"
Ttime="#&@"&time
if Len(Tcomments)<2 then
%>
<font size="4"
color="red">
<p align="center">对不起!你还未留言。<a href="book.asp">返回</a></font> <%
else
if Lcase(Left(Turl,7))<>"http://"
then
Turl="http://"&Turl
End if
Turl=Lcase(Turl)
set myText=fsFilesys.CreateTextFile(Server.MapPath("/"&"/realchat/book/book.txt"
myText.WriteLine(Tname)
myText.WriteLine(Tsex)
myText.WriteLine(Temail)
myText.WriteLine(Turl)
myText.WriteLine(Tfrom)
myText.WriteLine(Tcomments)
myText.writeLine(Ttime)
myText.WriteLine(date)
myText.writeLine(Temp)
myText.Close
%>
<script Language="JavaScript">
document.write("<h1>恭喜!您的留言已顺利提交,请按<a href='disp.asp'>这里</a>查看"
</script>
<%
end if
End if
else
%>
<html>
<head>
<title>留言薄</title>
<% colorbg="#BED9FC"
%>
</head>
<body bgcolor="<% =colorbg %>"
background="images/bg.gif">
<p align="center"><img src="images/gbook.gif"
alt="GBook.gif (12142 bytes)"
WIDTH="374"
HEIGHT="83"> </p>
<p align="center">[<a href="disp.asp">我要看留言板</a>]&nbsp;
[<a href="../index.asp">返回首页</a>]</p>
<form method="POST"
action="book.asp">
<input type="hidden"
name="task"
value="insert"><div align="left"><table>
<tr>
<td align="right">姓名</td>
<td><img src="images/bottom-b.gif"
alt="BUTTOM-B.GIF (179 bytes)"
WIDTH="16"
HEIGHT="16"></td>
<td><input name="name"
size="46"></td>
</tr>
<tr>
<td align="right">性别</td>
<td><img src="images/bottom-g.gif"
alt="BUTTOM-G.GIF (179 bytes)"
WIDTH="16"
HEIGHT="16"></td>
<td><input name="sex"
size="46"></td>
</tr>
<tr>
<td align="right">来自</td>
<td><img src="images/bottom-b.gif"
alt="BUTTOM-B.GIF (179 bytes)"
WIDTH="16"
HEIGHT="16"></td>
<td><input name="from"
size="46"></td>
</tr>
<tr>
<td align="right">主页URL</td>
<td><img src="images/homepage.gif"
alt="HomePage.gif (1232 bytes)"
WIDTH="30"
HEIGHT="30"></td>
<td><input name="url"
size="46"></td>
</tr>
<tr>
<td align="right">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
E-mail</td>
<td><img src="images/email.gif"
alt="Email.gif (1197 bytes)"
WIDTH="30"
HEIGHT="30"></td>
<td><input name="email"
size="46"></td>
</tr>
<tr>
<td align="right">留言</td>
<td colspan="2"><textarea wrap="off"
name="comments"
cols="49"
rows="9"></textarea></td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td colspan="2"><dl>
<dd align="center">&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit"
value="我写好了">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset"
value="重新再写"></dd>
</dl>
</td>
</tr>
</table>
</div>
</form>
<p align="center"> </p>
</body>
</html>
<%
end if
%>
现在到disp.asp这个文件,这个文件主要完成从book.txt中提取文件内容,然后重新生成HTML代码以显示出留言内容。
代码如下:
<% @language="vbscript"
%>
<html>
<head>
<title>留言薄</title>
</head>
<body background="images/back.gif">
<p align="center"><img src="images/gbook.gif"
alt="gbook.gif (12142 bytes)"
WIDTH="374"
HEIGHT="83"><%
set fsFilesys=CreateObject("Scripting.FileSystemObject"
set myText=fsFilesys.OpenTextFile(Server.MapPath("/"&"/realchat/book/book.txt"
Tname=myText.ReadLine
%> </p>
<p align="center">[<font color="#00FFFF"
size="4"><a href="book.asp">我要写留言</a></font>][<font color="#00FFFF"><a href="../index.asp">返回首页</a></font>]</p>
<table width="600">
<%
do while Tname<>"Line1"
Tsex=myText.ReadLine
Temail=myText.ReadLine
Turl=myText.ReadLine
Tfrom=myText.ReadLine
%>
<tr>
<td><hr>
</td>
</tr>
<tr>
<th colspan="2"
align="left">姓&nbsp;&nbsp;&nbsp;名:<% =Tname %><br>
性&nbsp;&nbsp;&nbsp;别:<% =Tsex %><br>
E—mail:<a href="mailto:<% =Temail %>"><% =Temail %></a><br>
主页URL:<a href="<% =Turl %>"
target="_blank"><% =turl %></a><br>
来&nbsp;&nbsp;&nbsp;自:<% =Tfrom %></th>
</tr>
<tr>
<th align="left"
bgcolor="<% =colorbg %>"><font color="red">留&nbsp;&nbsp;&nbsp;言:</font></th>
<th align="left"
bgcolor="<% =colorbg %>"><%
Tcomments=myText.ReadLine
do while InStr(Tcomments,"#&@"=0
%>
<% =Tcomments %>
<br>
<%
Tcomments=myText.ReadLine
loop
Ttime=Mid(Tcomments,4)
Tdate=myText.ReadLine
%> </th>
</tr>
<tr>
<th colspan="2"
align="left">时&nbsp;&nbsp;&nbsp;间:<% =Ttime %> <br>
日&nbsp;&nbsp;&nbsp;期:<% =Tdate %></th>
</tr>
<tr>
<td><br>
<%
tname=myText.ReadLine
loop
myText.Close
%> </td>
</tr>
</table>
<p><br>
<br>
</p>
</body>
</html>
*book.txt的内容,里面有一条留言
小Hu
男
realplay@163.net
http://realplay.163.net
佛山
热烈兴祝“泰信心动聊天室虚拟社区”进入测试使用阶断,衷
心感谢些您的到来,在测试过程中有什么问题或好的建议,请
告诉我。
网络之门系列站点诚邀您的加盟参与!
*文件名:book.htm
<html>
<head>
<title>留言薄</title>
</head>
<body bgcolor="#BED9FC"
background="images/bg.gif">
<p align="center"><img src="images/gbook.gif"
alt="GBook.gif (12142 bytes)"
WIDTH="374"HEIGHT="83"> </p>
<p align="center">[<a href="disp.asp">我要看留言板</a>]&nbsp;
[<a href="../index.asp">返回首页</a>]</p>
<form method="POST"
action="book.asp">
<input type="hidden"
name="task"
value="insert"><div align="left"><table>
<tr>
<td align="right">姓名</td>
<td><img src="images/bottom-b.gif"
alt="BUTTOM-B.GIF (179 bytes)"
WIDTH="16"
HEIGHT="16"></td>
<td><input name="name"
size="46"></td>
</tr>
<tr>
<td align="right">性别</td>
<td><img src="images/bottom-g.gif"
alt="BUTTOM-G.GIF (179 bytes)"
WIDTH="16"
HEIGHT="16"></td>
<td><input name="sex"
size="46"></td>
</tr>
<tr>
<td align="right">来自</td>
<td><img src="images/bottom-b.gif"
alt="BUTTOM-B.GIF (179 bytes)"
WIDTH="16"
HEIGHT="16"></td>
<td><input name="from"
size="46"></td>
</tr>
<tr>
<td align="right">主页URL</td>
<td><img src="images/homepage.gif"
alt="HomePage.gif (1232 bytes)"
WIDTH="30"
HEIGHT="30"></td>
<td><input name="url"
size="46"></td>
</tr>
<tr>
<td align="right">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
E-mail</td>
<td><img src="images/email.gif"
alt="Email.gif (1197 bytes)"
WIDTH="30"
HEIGHT="30"></td>
<td><input name="email"
size="46"></td>
</tr>
<tr>
<td align="right">留言</td>
<td colspan="2"><textarea wrap="off"
name="comments"
cols="49"
rows="9"></textarea></td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td colspan="2"><dl>
<dd align="center">&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit"
value="我写好了">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset"
value="重新再写"></dd>
</dl>
</td>
</tr>
</table>
</div>
</form>
<p align="center"> </p>
</body>
</html>
*book.asp
<% @language="vbscript"
%>
<%
if Request.ServerVariables("REQUEST_METHOD"="POST"
then
set fsFilesys=CreateObject("Scripting.FileSystemObject"
‘打开文本文件server.mappath("/"是返回服务器发行目录的真实路径,也就是比如说:c:/Inetpub/wwwroot这个路径,
然后"/realchat/book/book.txt"就是相对于这个路径基础上的路径。
set myText=fsFilesys.OpenTextFile(Server.MapPath("/"&"/realchat/book/book.txt"
Temp=myText.Readall
myText.Close
if Request("task"="insert"
then
Tname=request.form("name"
Tsex=request.form("sex"
Temail=request.form("email"
turl=request.form("url"
Tfrom=request.form("from"
Tcomments=request.form("comments"
Ttime="#&@"&time
if Len(Tcomments)<2 then
%>
<font size="4"
color="red">
<p align="center">对不起!你还未留言。<a href="book.asp">返回</a></font> <%
else
if Lcase(Left(Turl,7))<>"http://"
then
Turl="http://"&Turl
End if
Turl=Lcase(Turl)
set myText=fsFilesys.CreateTextFile(Server.MapPath("/"&"/realchat/book/book.txt"
myText.WriteLine(Tname)
myText.WriteLine(Tsex)
myText.WriteLine(Temail)
myText.WriteLine(Turl)
myText.WriteLine(Tfrom)
myText.WriteLine(Tcomments)
myText.writeLine(Ttime)
myText.WriteLine(date)
myText.writeLine(Temp)
myText.Close
%>
<script Language="JavaScript">
document.write("<h1>恭喜!您的留言已顺利提交,请按<a href='disp.asp'>这里</a>查看"
</script>
<%
end if
End if
else
%>
<html>
<head>
<title>留言薄</title>
<% colorbg="#BED9FC"
%>
</head>
<body bgcolor="<% =colorbg %>"
background="images/bg.gif">
<p align="center"><img src="images/gbook.gif"
alt="GBook.gif (12142 bytes)"
WIDTH="374"
HEIGHT="83"> </p>
<p align="center">[<a href="disp.asp">我要看留言板</a>]&nbsp;
[<a href="../index.asp">返回首页</a>]</p>
<form method="POST"
action="book.asp">
<input type="hidden"
name="task"
value="insert"><div align="left"><table>
<tr>
<td align="right">姓名</td>
<td><img src="images/bottom-b.gif"
alt="BUTTOM-B.GIF (179 bytes)"
WIDTH="16"
HEIGHT="16"></td>
<td><input name="name"
size="46"></td>
</tr>
<tr>
<td align="right">性别</td>
<td><img src="images/bottom-g.gif"
alt="BUTTOM-G.GIF (179 bytes)"
WIDTH="16"
HEIGHT="16"></td>
<td><input name="sex"
size="46"></td>
</tr>
<tr>
<td align="right">来自</td>
<td><img src="images/bottom-b.gif"
alt="BUTTOM-B.GIF (179 bytes)"
WIDTH="16"
HEIGHT="16"></td>
<td><input name="from"
size="46"></td>
</tr>
<tr>
<td align="right">主页URL</td>
<td><img src="images/homepage.gif"
alt="HomePage.gif (1232 bytes)"
WIDTH="30"
HEIGHT="30"></td>
<td><input name="url"
size="46"></td>
</tr>
<tr>
<td align="right">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
E-mail</td>
<td><img src="images/email.gif"
alt="Email.gif (1197 bytes)"
WIDTH="30"
HEIGHT="30"></td>
<td><input name="email"
size="46"></td>
</tr>
<tr>
<td align="right">留言</td>
<td colspan="2"><textarea wrap="off"
name="comments"
cols="49"
rows="9"></textarea></td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td colspan="2"><dl>
<dd align="center">&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit"
value="我写好了">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset"
value="重新再写"></dd>
</dl>
</td>
</tr>
</table>
</div>
</form>
<p align="center"> </p>
</body>
</html>
<%
end if
%>
现在到disp.asp这个文件,这个文件主要完成从book.txt中提取文件内容,然后重新生成HTML代码以显示出留言内容。
代码如下:
<% @language="vbscript"
%>
<html>
<head>
<title>留言薄</title>
</head>
<body background="images/back.gif">
<p align="center"><img src="images/gbook.gif"
alt="gbook.gif (12142 bytes)"
WIDTH="374"
HEIGHT="83"><%
set fsFilesys=CreateObject("Scripting.FileSystemObject"
set myText=fsFilesys.OpenTextFile(Server.MapPath("/"&"/realchat/book/book.txt"
Tname=myText.ReadLine
%> </p>
<p align="center">[<font color="#00FFFF"
size="4"><a href="book.asp">我要写留言</a></font>][<font color="#00FFFF"><a href="../index.asp">返回首页</a></font>]</p>
<table width="600">
<%
do while Tname<>"Line1"
Tsex=myText.ReadLine
Temail=myText.ReadLine
Turl=myText.ReadLine
Tfrom=myText.ReadLine
%>
<tr>
<td><hr>
</td>
</tr>
<tr>
<th colspan="2"
align="left">姓&nbsp;&nbsp;&nbsp;名:<% =Tname %><br>
性&nbsp;&nbsp;&nbsp;别:<% =Tsex %><br>
E—mail:<a href="mailto:<% =Temail %>"><% =Temail %></a><br>
主页URL:<a href="<% =Turl %>"
target="_blank"><% =turl %></a><br>
来&nbsp;&nbsp;&nbsp;自:<% =Tfrom %></th>
</tr>
<tr>
<th align="left"
bgcolor="<% =colorbg %>"><font color="red">留&nbsp;&nbsp;&nbsp;言:</font></th>
<th align="left"
bgcolor="<% =colorbg %>"><%
Tcomments=myText.ReadLine
do while InStr(Tcomments,"#&@"=0
%>
<% =Tcomments %>
<br>
<%
Tcomments=myText.ReadLine
loop
Ttime=Mid(Tcomments,4)
Tdate=myText.ReadLine
%> </th>
</tr>
<tr>
<th colspan="2"
align="left">时&nbsp;&nbsp;&nbsp;间:<% =Ttime %> <br>
日&nbsp;&nbsp;&nbsp;期:<% =Tdate %></th>
</tr>
<tr>
<td><br>
<%
tname=myText.ReadLine
loop
myText.Close
%> </td>
</tr>
</table>
<p><br>
<br>
</p>
</body>
</html>
*book.txt的内容,里面有一条留言
小Hu
男
realplay@163.net
http://realplay.163.net
佛山
热烈兴祝“泰信心动聊天室虚拟社区”进入测试使用阶断,衷
心感谢些您的到来,在测试过程中有什么问题或好的建议,请
告诉我。
网络之门系列站点诚邀您的加盟参与!