-------------------------------
<html><body bgcolor="#ffffff" text="#000000">
<b>this is my guestbook. use this form to submit your greeting:</b><br>
<form method="post" action="write.asp">
<input name="new_line" type="text" size=35>
<input type="submit" value="add greeting">
</form>
<br><br>
<%
myfile = "c:\guestbook.txt"
opens the guestbook file if it exists
set myfileobj=server.createobject("scripting.filesystemobject")
if myfileobj.fileexists(myfile) then
set mytextfile=myfileobj.opentextfile(myfile)
reads a line, and outputs it
while not mytextfile.atendofstream
%>
<hr>
<%=mytextfile.readline%>
</hr>
<%
wend
closes the textfile
mytextfile.close
end if does file exist
%>
<hr>
</body>
</html>
----------------------------
write.asp
----------------------------
<%
type in the path of the file to use. make sure that the script has write access.
myfile = "c:\guestbook.txt"
ready scripting.filesystemobject
set myfileobj=server.createobject("scripting.filesystemobject")
opens textfile. 8 = add line to file, true = create if it doesnt exists
set myoutstream=myfileobj.opentextfile(myfile, 8, true)
writes the line to the file
new_line = request.form("new_line")
new_line = server.htmlencode(new_line)
adds the time and date it was posted
new_line = "<i>posted: " & now & "</i><br>" & new_line
myoutstream.writeline(new_line)
closes the file
myoutstream.close
sends them back to the default page
response.redirect "default.asp"
%>
文章整理:站长天空 网址:http://www.z6688.com/
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




