Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: CGI Continue button

by erikharrison (Deacon)
on Jul 16, 2002 at 18:42 UTC ( #182196=note: print w/ replies, xml ) Need Help??


in reply to CGI Continue button

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


Comment on Re: CGI Continue button
Re: Re: CGI Continue button
by rob_au (Abbot) on Jul 16, 2002 at 23:04 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://182196]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-12-22 01:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (110 votes), past polls