GIDForums  

Go Back   GIDForums > Webmaster Forums > Web Design Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rating: Thread Rating: 70 votes, 4.99 average.
  #1  
Old 16-Oct-2003, 14:48
BobbyDouglas's Avatar
BobbyDouglas BobbyDouglas is offline
Regular Member
 
Join Date: Aug 2003
Posts: 789
BobbyDouglas has a spectacular aura aboutBobbyDouglas has a spectacular aura about

Guestbook error


Hey,

I am having a problem with my guestbook script.

When you goto example dot com /guest/addguest.html and try to add an entry you get:

500 Server Error
- when the server tries to run a script, an error occurred


Here is the code for the guestbook:

Code:
#!/usr/local/bin/perl -w ############################################################################## # Guestbook Version 2.3.1 # # Copyright 1996 Matt Wright mattw@worldwidemart.com # # Created 4/21/95 Last Modified 10/29/95 # # Scripts Archive at: http://www.worldwidemart.com/scripts/ # ############################################################################## # COPYRIGHT NOTICE # # Copyright 1996 Matthew M. Wright All Rights Reserved. # # # # Guestbook may be used and modified free of charge by anyone so long as # # this copyright notice and the comments above remain intact. By using this # # code you agree to indemnify Matthew M. Wright from any liability that # # might arise from it's use. # # # # Selling the code for this program without prior written consent is # # expressly forbidden. In other words, please ask first before you try and # # make money off of my program. # # # # Obtain permission before redistributing this software over the Internet or # # in any other medium. In all cases copyright and header must remain intact.# ############################################################################## # Set Variables $guestbookurl = "http://example.com/guest/guestbook.html"; $guestbookreal = "/home/exampl/guest/guestbook.html"; $guestlog = "/home/exampl/guest/guestlog.html"; $cgiurl = "http://example.com/cgi-bin/guestbook.pl"; $date_command = "/bin/date"; # Set Your Options: $mail = 0; # 1 = Yes; 0 = No $uselog = 1; # 1 = Yes; 0 = No $linkmail = 1; # 1 = Yes; 0 = No $separator = 1; # 1 = <hr>; 0 = <p> $redirection = 1; # 1 = Yes; 0 = No $entry_order = 1; # 1 = Newest entries added first; # 0 = Newest Entries added last. $remote_mail = 0; # 1 = Yes; 0 = No $allow_html = 0; # 1 = Yes; 0 = No $line_breaks = 1; # 1 = Yes; 0 = No # If you answered 1 to $mail or $remote_mail you will need to fill out # these variables below: $mailprog = '/usr/sbin/sendmail'; $recipient = 'YOUR_EMAIL_ADDRESS'; # Done ############################################################################## # Get the Date for Entry $date = `$date_command +"%A, %B %d, %Y at %T (%Z)"`; chop($date); $shortdate = `$date_command +"%D %T %Z"`; chop($shortdate); # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/<!--(.|\n)*-->//g; if ($allow_html != 1) { $value =~ s/<([^>]|\n)*>//g; } $FORM{$name} = $value; } # Print the Blank Response Subroutines &no_comments unless $FORM{'comments'}; &no_name unless $FORM{'realname'}; # Begin the Editing of the Guestbook File open (FILE,"$guestbookreal") || die "Can't Open $guestbookreal: $!\n"; @LINES=<FILE>; close(FILE); $SIZE=@LINES; # Open Link File to Output open (GUEST,">$guestbookreal") || die "Can't Open $guestbookreal: $!\n"; for ($i=0;$i<=$SIZE;$i++) { $_=$LINES[$i]; if (/<!--begin-->/) { if ($entry_order eq '1') { print GUEST "<!--begin-->\n"; } if ($line_breaks == 1) { $FORM{'comments'} =~ s/\cM\n/<br>\n/g; } print GUEST "<b>$FORM{'comments'}</b><br>\n"; if ($FORM{'url'}) { print GUEST "<a href=\"$FORM{'url'}\">$FORM{'realname'}</a>"; } else { print GUEST "$FORM{'realname'}"; } if ( $FORM{'username'} ){ if ($linkmail eq '1') { print GUEST " \&lt;<a href=\"mailto:$FORM{'username'}\">"; print GUEST "$FORM{'username'}</a>\&gt;"; } else { print GUEST " &lt;$FORM{'username'}&gt;"; } } print GUEST "<br>\n"; if ( $FORM{'city'} ){ print GUEST "$FORM{'city'},"; } if ( $FORM{'state'} ){ print GUEST " $FORM{'state'}"; } if ( $FORM{'country'} ){ print GUEST " $FORM{'country'}"; } if ($separator eq '1') { print GUEST " - $date<hr>\n\n"; } else { print GUEST " - $date<p>\n\n"; } if ($entry_order eq '0') { print GUEST "<!--begin-->\n"; } } else { print GUEST $_; } } close (GUEST); # Log The Entry if ($uselog eq '1') { &log('entry'); } ######### # Options # Mail Option if ($mail eq '1') { open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n"; print MAIL "Reply-to: $FORM{'username'} ($FORM{'realname'})\n"; print MAIL "From: $FORM{'username'} ($FORM{'realname'})\n"; print MAIL "Subject: Entry to Guestbook\n\n"; print MAIL "You have a new entry in your guestbook:\n\n"; print MAIL "------------------------------------------------------\n"; print MAIL "$FORM{'comments'}\n"; print MAIL "$FORM{'realname'}"; if ( $FORM{'username'} ){ print MAIL " <$FORM{'username'}>"; } print MAIL "\n"; if ( $FORM{'city'} ){ print MAIL "$FORM{'city'},"; } if ( $FORM{'state'} ){ print MAIL " $FORM{'state'}"; } if ( $FORM{'country'} ){ print MAIL " $FORM{'country'}"; } print MAIL " - $date\n"; print MAIL "------------------------------------------------------\n"; close (MAIL); } if ($remote_mail eq '1' && $FORM{'username'}) { open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n"; print MAIL "To: $FORM{'username'}\n"; print MAIL "From: $recipient\n"; print MAIL "Subject: Entry to Guestbook\n\n"; print MAIL "Thank you for adding to my guestbook.\n\n"; print MAIL "------------------------------------------------------\n"; print MAIL "$FORM{'comments'}\n"; print MAIL "$FORM{'realname'}"; if ( $FORM{'username'} ){ print MAIL " <$FORM{'username'}>"; } print MAIL "\n"; if ( $FORM{'city'} ){ print MAIL "$FORM{'city'},"; } if ( $FORM{'state'} ){ print MAIL " $FORM{'state'}"; } if ( $FORM{'country'} ){ print MAIL " $FORM{'country'}"; } print MAIL " - $date\n"; print MAIL "------------------------------------------------------\n"; close (MAIL); } # Print Out Initial Output Location Heading if ($redirection eq '1') { print "Location: $guestbookurl\n\n"; } else { &no_redirection; } ####################### # Subroutines sub no_comments { print "Content-type: text/html\n\n"; print "<html><head><title>No Comments</title></head>\n"; print "<body><h1>Your Comments appear to be blank</h1>\n"; print "The comment section in the guestbook fillout form appears\n"; print "to be blank and therefore the Guestbook Addition was not\n"; print "added. Please enter your comments below.<p>\n"; print "<form method=POST action=\"$cgiurl\">\n"; print "Your Name:<input type=text name=\"realname\" size=30 "; print "value=\"$FORM{'realname'}\"><br>\n"; print "E-Mail: <input type=text name=\"username\""; print "value=\"$FORM{'username'}\" size=40><br>\n"; print "City: <input type=text name=\"city\" value=\"$FORM{'city'}\" "; print "size=15>, State: <input type=text name=\"state\" "; print "value=\"$FORM{'state'}\" size=15> Country: <input type=text "; print "name=\"country\" value=\"$FORM{'country'}\" size=15><p>\n"; print "Comments:<br>\n"; print "<textarea name=\"comments\" COLS=60 ROWS=4></textarea><p>\n"; print "<input type=submit> * <input type=reset></form><hr>\n"; print "Return to the <a href=\"$guestbookurl\">Guestbook</a>."; print "\n</body></html>\n"; # Log The Error if ($uselog eq '1') { &log('no_comments'); } exit; } sub no_name { print "Content-type: text/html\n\n"; print "<html><head><title>No Name</title></head>\n"; print "<body><h1>Your Name appears to be blank</h1>\n"; print "The Name Section in the guestbook fillout form appears to\n"; print "be blank and therefore your entry to the guestbook was not\n"; print "added. Please add your name in the blank below.<p>\n"; print "<form method=POST action=\"$cgiurl\">\n"; print "Your Name:<input type=text name=\"realname\" size=30><br>\n"; print "E-Mail: <input type=text name=\"username\""; print " value=\"$FORM{'username'}\" size=40><br>\n"; print "City: <input type=text name=\"city\" value=\"$FORM{'city'}\" "; print "size=15>, State: <input type=text name=\"state\" "; print "value=\"$FORM{'state'}\" size=2> Country: <input type=text "; print "value=USA name=\"country\" value=\"$FORM{'country'}\" "; print "size=15><p>\n"; print "Comments have been retained.<p>\n"; print "<input type=hidden name=\"comments\" "; print "value=\"$FORM{'comments'}\">\n"; print "<input type=submit> * <input type=reset><hr>\n"; print "Return to the <a href=\"$guestbookurl\">Guestbook</a>."; print "\n</body></html>\n"; # Log The Error if ($uselog eq '1') { &log('no_name'); } exit; } # Log the Entry or Error sub log { $log_type = $_[0]; open (LOG, ">>$guestlog"); if ($log_type eq 'entry') { print LOG "$ENV{'REMOTE_HOST'} - [$shortdate]<br>\n"; } elsif ($log_type eq 'no_name') { print LOG "$ENV{'REMOTE_HOST'} - [$shortdate] - ERR: No Name<br>\n"; } elsif ($log_type eq 'no_comments') { print LOG "$ENV{'REMOTE_HOST'} - [$shortdate] - ERR: No "; print LOG "Comments<br>\n"; } } # Redirection Option sub no_redirection { # Print Beginning of HTML print "Content-Type: text/html\n\n"; print "<html><head><title>Thank You</title></head>\n"; print "<body><h1>Thank You For Signing The Guestbook</h1>\n"; # Print Response print "Thank you for filling in the guestbook. Your entry has\n"; print "been added to the guestbook.<hr>\n"; print "Here is what you submitted:<p>\n"; print "<b>$FORM{'comments'}</b><br>\n"; if ($FORM{'url'}) { print "<a href=\"$FORM{'url'}\">$FORM{'realname'}</a>"; } else { print "$FORM{'realname'}"; } if ( $FORM{'username'} ){ if ($linkmail eq '1') { print " &lt;<a href=\"mailto:$FORM{'username'}\">"; print "$FORM{'username'}</a>&gt;"; } else { print " &lt;$FORM{'username'}&gt;"; } } print "<br>\n"; if ( $FORM{'city'} ){ print "$FORM{'city'},"; } if ( $FORM{'state'} ){ print " $FORM{'state'}"; } if ( $FORM{'country'} ){ print " $FORM{'country'}"; } print " - $date<p>\n"; # Print End of HTML print "<hr>\n"; print "<a href=\"$guestbookurl\">Back to the Guestbook</a>\n"; print "- You may need to reload it when you get there to see your\n"; print "entry.\n"; print "</body></html>\n"; exit; }

Now on my server, I have perl installe correct(i believe at least). if you look at my cgi-bin folder you will see server.cgi and test.cgi that show perl is working.

This is what I have received from Ipowerweb with info on the errors...

Quote:
Thank you for contacting iPowerweb technical support.

I placed 2 scripts in your cgi-bin

The URL to them is listed below:

[edit]/cgi-bin/test.cgi
[edit]/cgi-bin/server.cgi

Both scripts do work.

Here is what the server is giving out in the logs:

Use of uninitialized value in read at guestbook.pl line 56.
Content-type: text/html

<html><head><title>No Comments</title></head>
<body><h1>Your Comments appear to be blank</h1>
The comment section in the guestbook fillout form appears
to be blank and therefore the Guestbook Addition was not
added. Please enter your comments below.<p>
<form method=POST action="[edit]/cgi-bin/guestbook.pl">
Use of uninitialized value in concatenation (.) or string at guestbook.pl line
254.
Your Name:<input type=text name="realname" size=30 value=""><br>
Use of uninitialized value in concatenation (.) or string at guestbook.pl line
256.
E-Mail: <input type=text name="username"value="" size=40><br>
Use of uninitialized value in concatenation (.) or string at guestbook.pl line
257.
Use of uninitialized value in concatenation (.) or string at guestbook.pl line
259.
Use of uninitialized value in concatenation (.) or string at guestbook.pl line
260.
City: <input type=text name="city" value="" size=15>, State: <input type=text
name="state" value="" size=15> Country: <input type=text name="country"
value="" size=15><p>
Comments:<br>
<textarea name="comments" COLS=60 ROWS=4></textarea><p>
<input type=submit> * <input type=reset></form><hr>
Return to the <a href="[edit]/guest/guestbook.html">Guestbook</a>.
</body></html>
Use of uninitialized value in concatenation (.) or string at guestbook.pl line
317.
print() on closed filehandle LOG at guestbook.pl line 317.
print() on closed filehandle LOG at guestbook.pl line 318.

Im not sure what to do now. The permissions for the guestbook are set to 755...
__________________
Mr. Bob's Web Design - Tirelessly looking for ways to enhance the customer base of your business.
  #2  
Old 16-Oct-2003, 22:17
BobbyDouglas's Avatar
BobbyDouglas BobbyDouglas is offline
Regular Member
 
Join Date: Aug 2003
Posts: 789
BobbyDouglas has a spectacular aura aboutBobbyDouglas has a spectacular aura about
I had the wrong address for the location of the site on the server, the home/exampl should be home/exampl/public_html

Something so simple
__________________
Mr. Bob's Web Design - Tirelessly looking for ways to enhance the customer base of your business.
 
 

Recent GIDBlogRunning Linux Programs at Boot Time by gidnetwork

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in ukrspp21 MySQL / PHP Forum 41 25-Jan-2010 19:51
Including Maps and strings?? maddie C++ Forum 17 05-Jul-2004 06:25
error during program rjd72285 C++ Forum 0 11-Nov-2003 18:49
[script] E-mail webmaster error page BobbyDouglas PHP Code Library 0 19-Aug-2003 20:10
CD burner, focus or tracking error ShingoDrrazz Computer Hardware Forum 1 09-Aug-2003 16:26

Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 14:38.


vBulletin, Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.