CGI.pm enables you to store a query object's state to a file for later retrieval. The use of this feature should solve your problem.

To store a query object to a file you should use CGI.pm's object-oriented style. Create a uniquely-named query object for each form you submit. Thus at the top of each form handler you might say something like: $myQueryObject = new CGI;.

You will need to find out the name of the user under which your CGI script runs. Let us say that this user is named 'web'. Then, at the end of your form handler open up a filehandle to a directory in which 'web' has read/write privileges. Then save the query object using that filehandle, e.g. $myQueryObject->save(FILEHANDLE).

If in a subsequent form handler you need to retrieve a value from a previous form, simply create a new query object from a filehandle that points to the file where you saved the previous query object, as in: $myPreviousQuery = new CGI(INPUTFILE);.

Finally, you can retrieve any parameter from the previous query object by using CGI.pm's param() function.

I have found that when opening up a previous query object it is better to use a reference to the file handle, e.g. $myPreviousQuery = new CGI(\*INPUTFILE);.


In reply to Re: Creating persistent table with CGI.pm by sierrathedog04
in thread Creating persistent table with CGI.pm by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.