by Doug Rice, doug.h.rice@btinternet.com
Although many ISPs do not allow Customer provided Server scripts, they provide a handful of standard scripts which implement web-counters, guestbooks and a form server.
This idea exploits the guestbook script, and suggests an very minor improvement to allow the client side JavaScript to sort the entries before display.
My Web Page can include a file containing a JavaScript Array, whic it can process. The modification requires that the standard CGI guestbook script appends the submitted guestbook entries onto the end of this file as JavaScript Array entries.
This neatly allows the client code to convert the order of guestbook entries from ordered by submission date to whatever the JavaScript can acheive.
I want a booking diary, so I need to extract out the requested date and present the data in that order.
If you did this BTInternet's security would not be compromised by rouge Customer CGI scripts. I would not have to write and mangage a booking system CGI script on a WebHost site. The idea could be customised by any reasonably JavaScript literate programmer, with minimal support from you.
Server processing is minised as the CGI script only need be run when the form is submitted. Only the JavaScript Include file is downloaded with my Web Page.
Instead of appending to the file GuestbookFile5.htm, the data like:
<p><b>From: </b>doug <br><b> Userfield1</b>101:126:4:2:10,7 <br><b> Userfield2</b>420-3, am, available, Wed, 26 Jan 2000 00:00:00 UTC <br><b> Userfield3</b>-,-,- <br><b> Userfield4</b>us4 <br><b>Posted on:</b> Tuesday, January 23, 2001, 08:20 PM</p><!--IP address is: 213.122.230.160--> Guestbook comment <hr>
I want you to append the form's data to a file called GuestBookFile5.JS :
/* Start of segment of code output by the BT internet CGI script */ /* This would be stored in guestbookfile5.js */ /* The array name guestBookFile5 is the same as the file name */ /* It whould be better if it was GB_n_X where n is the guestbook */ /* and X is a value posted up from the form */
guestBookFile5[ count ]= new GB( "name", "email", "postedOn", "IP address", "userfield1", "userfield2", "userfield3", "userfield4", "comments" ); count = count + 1
or for people who want more arrays in the same guestbook file:
/* Start of segment of code output by the BT internet CGI script */ /* It whould be better if the array name was GB_n_X where: */ /* n is the guestbook number e.g guestBookFilen */ /* X is a value posted up from the form using an input: */ /* <input type="hidden" name="GuestBookArrayName" value="X"> */
GB_n_X[ count_n_X ]= new GB( "name", "email", "postedOn", "IP address", "userfield1", "userfield2", "userfield3", "userfield4", "comments" ); count_n_X = count_n_X + 1
Where the text name, email, postedOn, IP address, userfield1, userfield2, userfield3, userfield4, and comments are what was entered into the guestbook form fields of these names.
It may be best to leave the form data escaped, as received from the form. It is then a simple matter for the WebPages code to unescape it using:
value = unesacape( guestBookFile5[ 1 ].name )
To configure the guestbook CGI to turn on this the form could have new hidden fields called: JavaScriptGuestBookName whoose value would be the filename to append to, and noHTMLguestbook which would suppress appending to the guestbookfilen.html that the script currently does.
Declare the form:
<form method="POST" name="F1" action = "/cgi-bin/guestbook/~doug.h.rice?guestbook=5" onsubmit="SubmitForm()">
<input type="hidden" name="nextpage" value="/~doug.h.rice/thanks5.htm">
<input type="hidden" name="usertitle1" value=" period day: ">
<input type="hidden" name="usertitle2" value=" Booking date: ">
<input type="hidden" name="usertitle3" value=" Month: ">
<input type="hidden" name="usertitle4" value=" Session type - Boat: ">
To turn on the JavaScript Array Append Add:
<input type="hidden" name="JavaScriptGuestBookFileName" value="guestbookfile.js ">
To customize the array name:
<input type="hidden" name="GuestBookArrayName" value="X">
where X replaces X below and n is the guestbook number ( 1 to 5 ) : GB_n_X[ count_n_X ]= new GB(
<input type="hidden" name="GuestBookArrayName" value="requests">
and if n=5 and X=requests, is output to guestBookFile5.js as:
GB_5_requests[ count_5_requests ] = new GB(
To turn off appending to the GuestBookFile.HTML Add:
<input type="hidden" name="noHTMLguestbook" value=" ">
In my Web Page I would have to include the code to access the guestbook:
<SCRIPT>
var count = 0
var guestBookFile5 = new Array()
function GB( name,email,postedOn,IPaddress,userfield1,userfield2,userfield3,userfield4,comments){
this.name = name
this.email = email
this.postedOn = postedOn,
this.IPaddress = IPaddress
this.userfield1 = userfield1
this.userfield2 = userfield2
this.userfield3 = userfield3
this.userfield4 = userfield4
this.comments = comments
return this
}
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript"; SRC="guestbookfile5.js"; </SCRIPT>
<SCRIPT>
<!--
My Javascript code to process the GuestBook Array and prepare the entries for the form to submit a new booking.
-->
</SCRIPT>
Welcome to the demo Sailing Club booking form.
After looking at the current bookings, enter the date, period and boat required. Press Validate to check the availabilty. If all validates, press the Submit button to confirm the booking. This will add your request to the end of the file http://www.btinternet.com/~doug.h.rice/guestbookfile5.htm
I would like BTInternet to save the information at the end of a file of javascript, as a new element in an array of structures.
In this version, a second window will display the JavaScript code to be added to guestbookfile5.js
To try this demo, save this page on your PC in a new directory and ensure that there is a file called guestbookfile5.js
Edit guestbookfile5.js with notepad and copy the new data structure onto the end of the file. Save it and reload this page to see your new booking.
See my page http://www.btinternet.com/~doug.h.rice/booking.htm
Current Bookings, as stored in GuestBookFile.js:-
The HTML based GuestBook, that you append to if you pressed Submit http://www.btinternet.com/~doug.h.rice/guestbookfile5.html
Updated By Doug Rice, 4th Feb 2001