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