in reply to Hand-rolled CGI mailto
I know that is a lot to grasp. But if you have the modules installed then by all means try it out. The benefit of this code is that each field name is only listed in the code once. Plus, the order that the fields are listed in is easily modified by changing the array @FIELD. Feel free to ask any questions. ;)use strict; use warnings; use CGI::Pretty qw(:standard); use MIME::Lite; my @FIELD = qw( name email address1 address2 city state zip homephone workphone business goals comments ); print header; if (param('mail_it')) { my $data = join('', map "$_: " . param($_) . "\n", @FIELD); my $msg = MIME::Lite->new( From => 'webmaster@prowebdesigner.net', To => 'webmaster@prowebdesigner.net', Subject => 'Website Design Request', Data => $data, ); if ($msg->send) { print start_html('The Thank You'), p(' YOUR potential business is VERY IMPORTANT to PRO WEB DESIGN. We will respond as soon as we can. '), ; print p('Here is what you submitted:'), ul( li[map b("\u$_\E: ") . param($_), @FIELD]), ; } else { print start_html('The Oopsie'), p('whoops! something went wrong!'), } } else { print start_html('The Form'), start_form, (map "$_: ".textfield($_).br, @FIELD), submit('mail_it'), end_form, ; } print end_html;
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|