Jump to content

guestbook.pl question


Guest daoverseer

Recommended Posts

Guest daoverseer

I have configured a guestbook.pl for my website...and it works great except for one little thing. When you type something in the comments box that ends up being a few lines long....and then click submit.....the posting displays the comments as one long line rather than wrapping them around into several lines....which then causes a scroll bar to appear at the bottom and you have to keep scrolling to the right to see the whole line. How can I make the comments wrap around to where the lines don't go over let's say 80 characters in length....which would then wrap around to the next line and so forth until it reaches the last letter?? I have been looking all over the internet for this answer. Any help is much appreciated.

 

THANKS!!

Link to comment
Share on other sites

Guest daoverseer

I am using a standard cgi script called guestbook.pl. It was taken from Matt's Script Archive. Everyone seems to be using his code in one fashion or another. A lot of people have modified it...but they say they used his code for the reference.

 

Here is what I think the HTML output code is. Maybe you can find what I am missing in there. I appreciate you getting back with me so quickly Sayonara³. I am sorry my post was a little vague. Hopefully this helps.

 

#######

#Opens 'guestbook.html' for writting

open (FILE,"$directory_gbook") || die "Can't Open $directory_gbook: $!\n";

@LINES=<FILE>;

close(FILE);

$SIZE=@LINES;

 

# Open Link File to Output

open (GUEST,">$directory_gbook") || die "Can't Open $directory_gbook: $!\n";

 

for ($i=0;$i<=$SIZE;$i++) {

$_=$LINES[$i];

if (/<!--add-->/) {

if ($entry eq '1') {

print GUEST "<!--add-->\n";

}

print GUEST "<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=0>\n";

if ( $FORM{'name'}) {

print GUEST "<TR><TD><B><font color=#FFFFFF>Name:</font></B></TD> <TD><font color=#FFFFFF>$FORM{'name'} - $date</font></TD></TR>\n

 

";

}

if ($FORM{'email'}) {

print GUEST "<TR><TD><B><font color=#FFFFFF>E-mail:</font></B></TD> <TD><A HREF=\"mailto:$FORM{'email'}\"> $FORM{'email'}</A></TD><

 

/TR>\n";

}

if ($FORM{'url'} ne "http://") {

print GUEST "<TR><TD><B><font color=#FFFFFF>My URL:</font></B></TD> <TD><A HREF=$FORM{'url'}>$FORM{'url'}</A></TD></TR>\n";

}

else {

}

if ( $FORM{'city'} ){

print GUEST "<TR><TD><B><font color=#FFFFFF>Location: </font></B></TD> <TD><font color=#FFFFFF>$FORM{'city'}</font>";

print GUEST ", <font color=#FFFFFF>$FORM{'state'}     $FORM{'country'}</font></TD></TR>\n";

}

print GUEST "<TR><TD VALIGN=top><B><font color=#FFFFFF>Comments:  </font></B></TD> \n";

print GUEST "<TD><font color=#FFFFFF>$FORM{'comments'}</font></TD></TR></TABLE><P>\n";

print GUEST "<CENTER><IMG SRC=\"$base$gif4\"></CENTER><BR>\n\n\n";

if ($entry eq '0') {

print GUEST "<!--add->\n";

}

}

else {

print GUEST $_;

}

}

close (GUEST);

Link to comment
Share on other sites

The problem is here:

 

print GUEST "<TD><font color=#FFFFFF>$FORM{'comments'}</font></TD></TR></TABLE><P>\n";

 

He's just putting the comments in straight from the form. On the form, carriage returns aren't done with <br> tags, they're done with newline (\n) escapes. You just need to add a bit of code to replace all occurences of '\n' with "<br>" in $FORM{'comments'} and you're done - unfortunately I don't know perl, so I can't help you there.

Link to comment
Share on other sites

Trouble is, perl makes rather excessive use of regexp (which I hate with a passion). I'd much rather use PHP instead, but obviously you've got a perl script so this isn't much help. Try looking for some kind of match operator, or something like that.

 

(In php, it's dead simple, just use str_replace :)).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.