source: text-formbuilder/trunk/bin/fb-cgi.pl @ 7

Last change on this file since 7 was 7, checked in by peter, 20 years ago

removed dependecies on YAML and Parse::RecDescent
renamed _dump to dump; now only tries to load YAML if it is called; non-fatal error if YAML cannot be loaded
modified bin/fb-cgi.pl
expanded docs

File size: 927 bytes
Line 
1use strict;
2use warnings;
3
4use Text::FormBuilder;
5use CGI;
6
7my $q = CGI->new;
8
9my $src_file = get_src_file($q->param('form_id'));
10
11my $parser = Text::FormBuilder->new;
12my $form = $parser->parse($src_file)->build(method => 'POST', params => $q)->form;
13
14if (1 or $form->submitted && $form->validate) {
15
16    # call storage function
17
18    my $plugin = 'DumpParams';
19   
20    eval "use $plugin;";
21    die "Can't use $plugin; $@" if $@;
22    die "Plugin $plugin doesn't know how to process" unless $plugin->can('process');
23
24    # plugin process method should return a true value
25    if ($plugin->process($q, $form)) {
26        # show thank you page
27    } else {
28        # there was an error processing the results
29        die "There was an error processing the submission: " . $plugin->error;
30    }
31   
32} else {
33    print $q->header;
34    print $form->render;
35}
36
37sub get_src_file {
38    my $form_id = shift;
39    return "$form_id.txt";
40}
Note: See TracBrowser for help on using the repository browser.