http://www.concentric.net/~virtuous/guestbook/guestbook.pl.txt
--
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content. You can SELF-APPROVE your first posting
by writing the word 'passme' on a line by itself.
open (GBOOK,">>$book_url") || die "Could Not Open $book_url: $!\n";
instead of:
open (GBOOK,">$book_url") || die "Could Not Open $book_url: $!\n";
Rick
Phantom wrote:
:
: Hello Everyone, I have recently learned Perl and I wrote my first guestbook
1. Remember to lock your file before writing to it :
(look at flock in the perl documentation).
2.
: open (GBOOK,">$book_url") || die "Could Not Open $book_url: $!\n";
this line will truncate the file pointed to by GBOOK and write to it.
You only write the form entries which was just submitted. Change it to:
open (GBOOK,">>$book_url") || die "Could Not Open $book_url: $!\n";
now it is opened for appending. (notice two '>')
I suspect that the line
print GUEST ("$line");
should really be
print GBOOK $line ;
because you don't have a file handle anywhere in the script named GUEST. I
assume you're opening the guestbook HTML file, reading the whole thing, the
opening it for writing (thus erasing the whole thing), writing it back from
memory until you find a certain HTML comment, then writing the new entry, then
writing the rest of the file from memory. Unfortunately, it's that last part,
writing the rest of the file from memory that's not happening because it's
trying to print to a file handle that doesn't exist.
Good luck.
PS-take a look at implementing the comments from the other posts like file
locking, etc. The problem I found is just one of the problems you might
encounter with the script.
--
Jay Eckles
www.ecklesweb.com
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
Thanks Again,
Mark.