| | |
Guestbook help. Post in two different spots.
Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
![]() |
The only thing that this code does:
is loop through each line of the file, and sets the default variable ($_) to the next line in the file. Basically, it's reading the HTML file line by line, and replacing $_ with the next line after the loop. So, It reads line1, checks to see if it's <!--begin-->, and then does something if it is.... if not, it just reads the next line, and keeps doing so. Every time you see a "print GUEST" it's writing something new to the HTML document. This line here:
Is actually writing "everything else" to the file. That's how it makes sure not to lose any other posts or anything. It just writes it back to the file. The reason the <!--begin--> exists, is solely so the script knows WHERE to add it's new record in the file. This also means that it doesn't reach the code posted above (the else), because the else only gets called should the line NOT be "<!--begin-->", meaning the stuff in the file doesn't get re-written. Give this a shot:
Perl Syntax (Toggle Plain Text)
for ($i=0;$i<=$SIZE;$i++) { $_=$LINES[$i]; }
Perl Syntax (Toggle Plain Text)
else { print GUEST $_;
Perl Syntax (Toggle Plain Text)
for ($i=0;$i<=$SIZE;$i++) { $_=$LINES[$i]; ####THIS IS THE PART I ADDED#########################33 if (/<!--links-->/) { print GUEST "<!--links-->\n"; # /* I Added This */ print GUEST "TEST LINK<br>\n"; } else { # /* I Added This */ ##########I ADDED THE STUFF ABOVE THIS LINE################ if (/<!--begin-->/) { if ($entry_order eq '1') { print GUEST "<!--begin-->\n"; } if ( $FORM{'storyname'} ){ print GUEST "<h1><b><center>$FORM{'storyname'}</center></h1></b><br>\n"; } print GUEST "<a href=\"#Top\"><u>(return to top)</u></a><br>\n"; if ($FORM{'url'}) { print GUEST "<a href=\"$FORM{'url'}\">$FORM{'realname'}</a>"; } else { print GUEST "Submitted by: <b>$FORM{'realname'}</b><br>"; } if ( $FORM{'username'} ){ if ($linkmail eq '1') { print GUEST " \<<a href=\"mailto:$FORM{'username'}\">"; print GUEST "$FORM{'username'}</a>\>"; } else { print GUEST "Email: <b>$FORM{'username'}</b>"; } } print GUEST "<br>\n"; print GUEST "Date Submitted: $date<br>\n"; if ( $FORM{'intro'} ){ print GUEST "Story Introduction: $FORM{'intro'}<p>\n"; } print GUEST "<b>Story:</b><br>\n"; $story=$FORM{'story'}; $story =~s/\n/<br>/gi; print GUEST "$story\n"; print GUEST "<hr>\n\n"; if ($entry_order eq '0') { print GUEST "<!--begin-->\n"; } } else { print GUEST $_; } } } # /* I Added This */
![]() |
Similar Threads
- editing the appearance of entries in a guestbook (HTML and CSS)
- Advertising spots available on our Paid-To-Post forum (Ad Space for Sale)
Other Threads in the Perl Forum
- Previous Thread: Newbie Needs Help
- Next Thread: Win32 API Struct
| Thread Tools | Search this Thread |






