Guestbook help. Post in two different spots.

Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Guestbook help. Post in two different spots.

 
0
  #11
May 28th, 2005
The only thing that this code does:
  1. for ($i=0;$i<=$SIZE;$i++) {
  2. $_=$LINES[$i];
  3. }
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:
  1. else {
  2. print GUEST $_;
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:
  1. for ($i=0;$i<=$SIZE;$i++) {
  2. $_=$LINES[$i];
  3. ####THIS IS THE PART I ADDED#########################33
  4. if (/<!--links-->/) {
  5. print GUEST "<!--links-->\n"; # /* I Added This */
  6. print GUEST "TEST LINK<br>\n";
  7. } else { # /* I Added This */
  8.  
  9. ##########I ADDED THE STUFF ABOVE THIS LINE################
  10.  
  11. if (/<!--begin-->/) {
  12.  
  13. if ($entry_order eq '1') {
  14. print GUEST "<!--begin-->\n";
  15. }
  16.  
  17.  
  18. if ( $FORM{'storyname'} ){
  19. print GUEST "<h1><b><center>$FORM{'storyname'}</center></h1></b><br>\n";
  20. }
  21. print GUEST "<a href=\"#Top\"><u>(return to top)</u></a><br>\n";
  22.  
  23. if ($FORM{'url'}) {
  24. print GUEST "<a href=\"$FORM{'url'}\">$FORM{'realname'}</a>";
  25. }
  26. else {
  27. print GUEST "Submitted by: <b>$FORM{'realname'}</b><br>";
  28. }
  29.  
  30. if ( $FORM{'username'} ){
  31. if ($linkmail eq '1') {
  32. print GUEST " \<<a href=\"mailto:$FORM{'username'}\">";
  33. print GUEST "$FORM{'username'}</a>\>";
  34. }
  35. else {
  36. print GUEST "Email: <b>$FORM{'username'}</b>";
  37. }
  38. }
  39.  
  40. print GUEST "<br>\n";
  41. print GUEST "Date Submitted: $date<br>\n";
  42.  
  43.  
  44.  
  45.  
  46. if ( $FORM{'intro'} ){
  47. print GUEST "Story Introduction: $FORM{'intro'}<p>\n";
  48. }
  49.  
  50.  
  51.  
  52. print GUEST "<b>Story:</b><br>\n";
  53. $story=$FORM{'story'};
  54. $story =~s/\n/<br>/gi;
  55. print GUEST "$story\n";
  56.  
  57.  
  58. print GUEST "<hr>\n\n";
  59.  
  60.  
  61. if ($entry_order eq '0') {
  62. print GUEST "<!--begin-->\n";
  63. }
  64.  
  65. }
  66. else {
  67. print GUEST $_;
  68. }
  69. }
  70. } # /* I Added This */
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Perl Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC