Don't ask to ask, just ask | |
PerlMonks |
Re: Multiple forms in one CGI file?by davorg (Chancellor) |
on Jan 30, 2007 at 09:29 UTC ( [id://597320]=note: print w/replies, xml ) | Need Help?? |
A CGI program accepts inputs from the browser, processes them in some way and then produces an output (which is usually an HTML page to be displayed by the browser). There is no reason why the HTML produced by the CGI program can't include another form which will then call another CGI program (or even the same CGI program again). If you're calling the same CGI program to handle different stages of a process, then you need to give it some way to distinguish which stage each call needs to process. The easiest way to do this is to have a hidden input (I usually call it 'mode') on the form. I often find myself writing CGI programs that look a bit like this:
The output templates are either stored in external files, or in the DATA section using Inline::Files. Of course, these days, you're probably better off using a framework like Catalyst. Update: Fixed problems noted by blazar below.
-- "The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg
In Section
Seekers of Perl Wisdom
|
|