Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

In essence, what you is a state problem. HTTP is a stateless protocol, which means that no transaction remembers anything about the prior transaction. However, there are a couple of ways to "fake" state retention in a CGI script.

  1. When your user submits this data, you have the files saved to temp files and the text fields in to scalars ($foo and $baz). Untaint $foo and $baz, slap them in a database. Add the names of the temp files to this database. In the second HTML page (which fuzzyping rightly directs to CGI::Application to handle) plant a hidden form field with the key to those database entries. Have a submit button with a "continue" value, and if the script recieves a continue vale it checks the hidden parameter for the database key, and pulls out all the right info to do appropriate things with. If not, it redirects to the correct page, and deletes the entry in the database and the temp files.
  2. Doing the above but using cookies to maintain state.
  3. Since you are presenting the user with formatted data, embed that formatted data into a hidden form field on the page, and have a submit button with a "continue" value. If the script recieves the "continue" value, it checks the hidden param for the preformatted data and does appropriate things.
  4. I'd go with #1. It's a little more work than #3 but is cleaner, scales better, and is more readily extensible. #2 is really just there for completeness, as cookies are a bad fit for this problem UNLESS this is a largeish website with a user logon already in place. If this is the case, then the user already has a cookie, and you can leverage that for state maintenance.

    Cheers,
    Erik

    Light a man a fire, he's warm for a day. Catch a man on fire, and he's warm for the rest of his life. - Terry Pratchet


    In reply to Re: CGI Continue button by erikharrison
    in thread CGI Continue button by neilwatson

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



    • Are you posting in the right place? Check out Where do I post X? to know for sure.
    • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
      <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
    • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
    • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-19 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found