| The Guestbook CGI code#********* BEGIN BODY******************** open (LOGFILE, ">>guestbook.log"); $newline=join('::',@value); print LOGFILE ("$newline\n"); close LOGFILE; print "<BODY BGCOLOR='BEIGE'><H1>Thank you. ";
#******** END BODY************************
The first line of the code is this:
After the comma and the quotes, the name of the file begins with 2 Greater-than signs >>. This is one of about 12 special symbols to determine what kind of input or output is being opened. Will the program read from this file? Will it write to it? Will it do both? Will it overwrite it? There are 3 symbols that I use frequently here:
The next line is the join statement. This is an extremely
useful tool for adding data to delimited text files. The statement
$newline could now contain this:
Now that $newline is complete, I am ready to add it to the end of guestbook.log.
Since I already have a file handle for the log file, appending to it is
as easy as this:
close LOGFILE;
Lastly, I printed something to the screen. This is more than just a courtesy. You have to write something or else you get a 'document contains no data' error. So we wrote this: print "<BODY BGCOLOR=\'BEIGE\'><H1>Thank you. Your comments
have been added</H1>";
| ||
| |||
Home | WebData - Web Database Software | Javascript | CGI | Consulting | Map Builder | Contact Us | The Press Room |