Displaying Guestbook Entries from a File

Introduction

Guestbooks allow you to collect and format comments from web site visitors for display on your web site. The basic method of collecting guestbook entries is for visitors to complete and submit a form with their contact information and comments. When the form is processed, the guestbook entry is formatted and written to the specified location in a file (newer entries are written above older entries). Guestbook entries are then read by viewing the display file.

In this example, a store is collecting comments about their products.

MGI Tags

Steps

  1. Create a form to collect guestbook information.
  2. Create a guestbook processing page and open it in a text editor.
  3. Insert the mgiGuestbook tag.
  4. Save the guestbook processing page.
  5. Create a page to display guestbook entries and open it in a text editor.
  6. Insert the Guestbook Insertion Marker.
  7. Save the guestbook display page.
  8. FTP the guestbook form, guestbook processing page and guestbook display page to the web server running MGI.
  9. View the guestbook form in a web browser and submit an entry.


Step 1: Create a form to collect guestbook information.

Create a guestbook form with form elements. In this example, the guestbook form consists of text fields for the visitor's Name, Location and Comments. Name each form element uniquely. Enclose all form elements with HTML <FORM> tags and post the form to the guestbook processing page (processgb.mgi).
 
This is an example guestbook form.
<form action="processgb.mgi" method="post">

<center>
<h2>Sign Our Guestbook</h2>

<p><table cellpadding="3" cellspacing="0">

<tr><td>Name:</td>
<td><input type="text" name="Name" size="30">
</td></tr>

<tr><td>Location (City, State):</td>
<td><input type="text" name="Location" size="30">
</td></tr>

<tr><td>Comments:</td>
<td><textarea name="Comments" rows="5" cols="30">
</textarea></td></tr>

<tr><td>&nbsp;</td>
<td><input type="submit" value="Post Comments">
</td></tr>

</table>
</center>

</form>

Step 2: Create a guestbook processing page and open it in a text editor.

Create a page named "processgb.mgi" to format each guestbook entry and write the entry to the guestbook display page. Open the page in a text editing program that allows you to view and modify the HTML and code of the page.

Step 3: Insert the mgiGuestbook tag.

Enter the beginning mgiGuestbook tag, fileLocation parameter, and ending mgiGuestbook tag. In the fileLocation parameter, enter the name of the guestbook display page (displaygb.mgi). In the body of the mgiGuestbook tags, enter text, HTML, and MGI tags to format each guestbook entry.
 
This is an example guestbook processing page.
<h2>Thank You</h2>

<p>Your comments are appreciated.  
<a href="displaygb.mgi">Click here to 
read all comments.</a>

<mgiGuestbook fileLocation="displaygb.mgi">
<table width="400" cellpadding="3" cellspacing="0">
<tr>
<td bgcolor="#99cc99"><b><mgiPostArgument name="Name"> of 
<mgiPostArgument name="Location"></b></td>
</tr>
<tr>
<td><font color="#660099">
<mgiPostArgument name="Comments"></font></td>
</tr>
</table>
</mgiGuestbook>

Step 4: Save the guestbook processing page.

Save the changes you have made to the guestbook processing page.

Step 5: Create a page to display guestbook entries and open it in a text editor.

Create a named "displaygb.mgi" to display guestbook entries and open the page in a text editing program that allows you to view and modify the HTML and code of the page.

Step 6: Insert the Guestbook Insertion Marker.

On the guestbook display page, insert the Guestbook Insertion Marker. The Guestbook Insertion Marker is written in the style of an HTML comment that designates where guestbook entries are displayed.
 
This is an example guestbook display page.
<center>

<h2>This is what our fine customers had to say:</h2>

<!-- Guestbook Insertion Marker -->

</center>

Step 7: Save the guestbook display page.

Save the changes you have made to the guestbook display page.

Step 8: FTP the guestbook form, guestbook processing page and guestbook display page to the web server running MGI.

Upload the guestbook form, guestbook processing page and guestbook display page from your local computer to the web server using an FTP program.

Step 9: View the guestbook form in a web browser and submit an entry.

View the guestbook form in a web browser. Complete the guestbook form and submit an entry. View the guestbook display page. Your entry will appear on the guestbook display page:

Sandra Clemmons of Maryland
Your products are the best. Keep up the good work. I am looking forward to the new line that is due out in March.

Pete Wilson of Atlanta, Georgia
Just wanted to say that my last order was a hit at my party. That is why today I am ordering some more. Also could you please tell me when will be the latest date I can order for xmas holidays... Have yourself a great day!

Each new guestbook entry is added to the display page at the location of the guestbook insertion marker. Newer guestbook entries appear before older guestbook entries.


[Return to the Guestbooks Menu]


[Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]


[MGI Guides Main Menu] [User Guide Main Menu]