acidhoss
12-03-2002, 09:50 PM
Allo again
I had to reboot my comp a little while ago, so I wrote this new guestbook in perl using a tutorial from about.com using cgi.pm. I'm not really familiar with cgi.pm, or any other perl modules for that matter, so i was wondering if someone could help me with this problem i am having:
when i run it, it seems to work fine, it prints out the form and everything, but when i submit it, nothing happens. So, i checked my apache error log file, and it said this:
"[Tue Dec 03 15:12:18 2002] [error] [client 127.0.0.1] Can't open GUESTBOOK:C:/perl/htdocs/guestbook.html: No such file or directory"
I restarted apache, tried it again, and then it said this:
"[Tue Dec 03 15:20:30 2002] [error] [client 127.0.0.1] File does not exist: c:/perl/htdocs/guestbook.htm"
weird, huh?
Here is the script, if some one could help me by pm me or just responding to this, that would be great.
Btw, i am running indigo perl mod_perl ver. 1.25 on windows me.
THE SCRIPT:
#!perl
##################################################
#Guestbook by dhoss of twisted hamster designs
#written with cgi.pm
#################################################
use strict;
use CGI;
#FIle path names
#relative (absolute, actually) path to guestbook file
my $guestbook = "C:/perl/htdocs/guestbook.html";
#guestbook url
my $guestbookurl = "http://oemcomputer/guestbook.html";
#initialize months for later use in date
my @month = ("January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December");
#Start to use CGI.pm
my $query = new CGI();
print $query->header;
print $query->start_html('Add your name!');
#Create the user input form
print $query->start_form,
"Your name:", $query->textfield('name'),
$query->p,
"City:", $query->textfield('city'),
$query->p,
"Comments",$query->br,
$query->textarea(-name,=>'comments', -rows=>10,-columns=>50),
$query->p,
$query->submit('Add me!'),
$query->p,
$query->end_form,
$query->hr,
$query->p,
#ok, now get the date and time infor
my ($Seconds, $Minutes, $Hours, $DayInMonth, $Month, $ShortYear, $DayOfWeek, $DayOfYear, $IsDST);
($Seconds, $Minutes, $Hours, $DayInMonth, $Month, $ShortYear, $DayOfWeek, $DayOfYear, $IsDST) = localtime(time);
#Fix it to keep it Y2K compliant
my $Year = $ShortYear + 1900;
my $EntryDate = "$month[$Month]$DayInMonth,$Year";
#Open the guestbook file and read it into an array
open(GUEST,"$guestbook") || die "Can't open GUESTBOOK:$guestbook: $!\n";
my @GUEST = <GUESTBOOK>;
close(GUEST);
#Open it once more, this time to write to it
open(GUEST,">$guestbook") || die "Can't open GUESTBOOK:$guestbook: $!\n";
my $line;
foreach $line(@GUEST){
#Check and see if we are at the beginning of the guestbook file
if($line=~/<!--START:-->/i){
#We are, so start adding the entry
#Start with adding the header <!--START:--> so we can find where we are next time the guest
#book is signed
print GUEST "<!--START:-->\n";
#Make sure the user entered data to be written to the guestbook file
if($query->param('name')){
{
print GUEST "<DL>\n";
if($query->param('email')){
#if they gave and email address, add it as a link
print GUEST $query->em($query->b($query->a
({href=>"mailto:".$query->param('email')},
$query->param('name')) ) );
print GUEST $query->br;
}
else{
#otherwise, just add their name
print GUEST $query->em($query->b($query->param('name')));
print GUEST $query->br;
}
#add the city
if($query->param('city')){
print GUEST $query->em($query->param('city'));
print GUEST $query->br;}
#add the comments
if($query->param('comments')){
print GUEST $query->em($query->param('comments'));
print GUEST $query->br;}
#add the date
print GUEST $query->em("Signed on $EntryDate");
#finish it all up
print GUESTBOOK "</DL>\n";
print GUEST $query->hr;
}
}
else {
#just put the existing line in the file
print GUEST "$line";
}
}
close(GUEST);
print $query->h1('Thanks!');
print "Your entry has been added to the ", $query->a( {-href=>$guestbookurl}, 'guestbook'), ". You may need to click reload to view your guestbook entry.";
}
Help me with this noodle scratcher if ya can.
Gracias.
I had to reboot my comp a little while ago, so I wrote this new guestbook in perl using a tutorial from about.com using cgi.pm. I'm not really familiar with cgi.pm, or any other perl modules for that matter, so i was wondering if someone could help me with this problem i am having:
when i run it, it seems to work fine, it prints out the form and everything, but when i submit it, nothing happens. So, i checked my apache error log file, and it said this:
"[Tue Dec 03 15:12:18 2002] [error] [client 127.0.0.1] Can't open GUESTBOOK:C:/perl/htdocs/guestbook.html: No such file or directory"
I restarted apache, tried it again, and then it said this:
"[Tue Dec 03 15:20:30 2002] [error] [client 127.0.0.1] File does not exist: c:/perl/htdocs/guestbook.htm"
weird, huh?
Here is the script, if some one could help me by pm me or just responding to this, that would be great.
Btw, i am running indigo perl mod_perl ver. 1.25 on windows me.
THE SCRIPT:
#!perl
##################################################
#Guestbook by dhoss of twisted hamster designs
#written with cgi.pm
#################################################
use strict;
use CGI;
#FIle path names
#relative (absolute, actually) path to guestbook file
my $guestbook = "C:/perl/htdocs/guestbook.html";
#guestbook url
my $guestbookurl = "http://oemcomputer/guestbook.html";
#initialize months for later use in date
my @month = ("January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December");
#Start to use CGI.pm
my $query = new CGI();
print $query->header;
print $query->start_html('Add your name!');
#Create the user input form
print $query->start_form,
"Your name:", $query->textfield('name'),
$query->p,
"City:", $query->textfield('city'),
$query->p,
"Comments",$query->br,
$query->textarea(-name,=>'comments', -rows=>10,-columns=>50),
$query->p,
$query->submit('Add me!'),
$query->p,
$query->end_form,
$query->hr,
$query->p,
#ok, now get the date and time infor
my ($Seconds, $Minutes, $Hours, $DayInMonth, $Month, $ShortYear, $DayOfWeek, $DayOfYear, $IsDST);
($Seconds, $Minutes, $Hours, $DayInMonth, $Month, $ShortYear, $DayOfWeek, $DayOfYear, $IsDST) = localtime(time);
#Fix it to keep it Y2K compliant
my $Year = $ShortYear + 1900;
my $EntryDate = "$month[$Month]$DayInMonth,$Year";
#Open the guestbook file and read it into an array
open(GUEST,"$guestbook") || die "Can't open GUESTBOOK:$guestbook: $!\n";
my @GUEST = <GUESTBOOK>;
close(GUEST);
#Open it once more, this time to write to it
open(GUEST,">$guestbook") || die "Can't open GUESTBOOK:$guestbook: $!\n";
my $line;
foreach $line(@GUEST){
#Check and see if we are at the beginning of the guestbook file
if($line=~/<!--START:-->/i){
#We are, so start adding the entry
#Start with adding the header <!--START:--> so we can find where we are next time the guest
#book is signed
print GUEST "<!--START:-->\n";
#Make sure the user entered data to be written to the guestbook file
if($query->param('name')){
{
print GUEST "<DL>\n";
if($query->param('email')){
#if they gave and email address, add it as a link
print GUEST $query->em($query->b($query->a
({href=>"mailto:".$query->param('email')},
$query->param('name')) ) );
print GUEST $query->br;
}
else{
#otherwise, just add their name
print GUEST $query->em($query->b($query->param('name')));
print GUEST $query->br;
}
#add the city
if($query->param('city')){
print GUEST $query->em($query->param('city'));
print GUEST $query->br;}
#add the comments
if($query->param('comments')){
print GUEST $query->em($query->param('comments'));
print GUEST $query->br;}
#add the date
print GUEST $query->em("Signed on $EntryDate");
#finish it all up
print GUESTBOOK "</DL>\n";
print GUEST $query->hr;
}
}
else {
#just put the existing line in the file
print GUEST "$line";
}
}
close(GUEST);
print $query->h1('Thanks!');
print "Your entry has been added to the ", $query->a( {-href=>$guestbookurl}, 'guestbook'), ". You may need to click reload to view your guestbook entry.";
}
Help me with this noodle scratcher if ya can.
Gracias.
