This topic always piques my interest, particularly becuase everyone encounters it at some time in their CGI life. The question is, really: what is the user trying to do during this particular request? One hint is the request type itself: GET, POST, HEAD, etc.
Here's what I do (similar to your method, I think):
1. post to the same page with a unique variable, like go=1
2. check for go=1, then do form processing
You could also post to a different CGI or a different subroutine in the same CGI, and simply posting to that CGI or sub indicates that form processing is to take place.
I really enjoy the speed and freedom of mod_perl for this reason... you could probably implement a pretty complex state machine to know at what point a user is in a particular process (logging on, posting a message, etc.).
"This process seems ineficiant and error prone."
I guess this depends on the programmer, right?
If anyone knows more about state machines (links, info, whatever) please post!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.