The other way to handle it is quick and dirty but cheap and easy to do which is chady's idea of a 'flatfile' - or just a text file that contains the comments.
Things to keep in mind. Unless you force it you cannot be assured that all of the comments are going to be on one line. It makes more sense to use a unique seperator between entries. From seperator to seperator counts as one entry. I ripped this out of another program of mine to show you how I did it.
This builds an array of entries. Each entry will correspond to one guest book entry. Then, to print out a subset of them you use a very very simple for loopsub read_quotes { open (QUOTES, "< $basedir$quotefile") || die "No quotes file!" +; while (<QUOTES>) { chomp; if (!($_ eq $seperator)) { $build .= "$_\n"; } else { push(@quotes,$build); $build = "-------\n"; #seperate body from sig } } close QUOTES; }
$max and $min are the upper and lower bounds of the arrays section you want to print. For example, if you want to print 10 entries per pages the $min and $max for the 1st page would be 0 and 9. The 2nd page would be 10 and 19, 20 and 29 for the 3rd and so on. The max and min can be set with hidden values that are submitted when the user clicks on the 'next page' button.for ($i = $min; $i <= $max; $i++) { print $quotes[$i]; }
One note about the design of this... The simplest thing in the world would be to run this all from the cgi-bin directory in one script. The template Chady talks about should just be part of your perl code. Do something like this;
Make use of the CGI modules if you can to save time especially with parsing the user data. Enjoy.script starts if no arguements print 1st page of guestbook exit else is arguement 'next page'? print page N build next page button with values for next page is argument 'previous page'? same as above but in reverse :) is argument 'add entry'? parse user entry and concatonate to end of guestbook file script ends
In reply to Re: Max Submissions?
by rapier1
in thread Max Submissions?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |