|
|
 |
|
Lesson 4: Add an ASP guestbook! |
|
Lesson 4: Add an ASP guestbook!
Summary:
Learn to make an ASP guestbook in VBScript.
View the demo to see the result.
Intro:
I've had some requests for a guestbook script. And since it's
a good way to learn to read/write files, I made this the next
lesson. Besides, it's easily modified to become a traffic log. (And
I know how cool it is to see that someone has visited your site.)
The code:
The guestbook consists of 3 parts:
Display. Showing the content of the guestbook file.
Form. So that visitors can add their greeting.
Write. A script that adds the greeting to the guestbook file.
The code is pretty easy and well commented. Just download it and
see for yourself. Make sure to change the MyFile to the file that
you're going to use. And remember that the script must have write access
to the file. That means that you should put it in your CGI-BIN folder
(That's what I had to do).
File list:
Default.asp Display and form
Write.asp Writes to the file, and redirects to default.asp.
Download code
Modifications:
You can make this more advance in a billion ways.
You can add fields for the name and email address,
or maybe let people upload a picture of themselves.
If you want the newest posts to be on top, you need
to read every line into an array,
then loop backward through the array and output the lines!
Another solution is using a database instead of text files
to store the messages.
Where to go next:
Go to lesson 3 to learn how to build
an live ASP chat.
Take a look at our lessons page
to get an overview of all our lessons.
| |
|
|
 |
|