Title: RE: Emailing forms w/data intact

I want to let a user click a link which runs a Perl program, passing a filename on the query string (like http://www.domain.com/cgi-bin/process_form.pl?form=testform.html). Easy.

Then, after the user fills out and submits the form, I want to combine the user's responses and the form, and save it in a separate HTML file. In other words, I want a file that looks just like what the user filled out, with the data. Tough (?).

Finally, I want to email that document to another party. Easy.

I created a fairly nice script which you can place an HTML form into. (You only need to insert perl variables strategically.) I'd rather not create 100 similar Perl applications if I can help it. :)

Can this be done? I think it can be using CGI.pm.

-WM  <><

-----Original Message-----
From: Cameron Dorey [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 07, 2000 4:26 PM
To: [EMAIL PROTECTED]
Subject: Re: Emailing forms w/data intact


> [EMAIL PROTECTED] wrote:
>
> Can someone wind me up and point me in the right direction?
>
> I'm trying to let users submit an HTML form into a file, with data
> intact.  About 100 forms (in HTML files) were created by a couple of
> interns last summer, and I'd prefer to pass the form name as part of
> the query string (like process_form.pl?form=testform.html).
>
> I've looked at CGI.pm
> (http://www.perl.com/pub/doc/manual/html/lib/CGI.html), and the tools
> are right there, but I can't seem to piece them together.
>
> I know well how to fetch data from a submit, how to process it, how to
> email a file, etc., and I've used Perl for about two years. It's
> re-inserting the data back into a form that I'm stumbling over.
>
> Here's where I'm at now, for starters.
>
> [code snipped]

Good golly, Miss Molly, pardon me, but what are you trying to do here
with all those split/tr/packs? CGI.pm lets you work with forms without
having to do all the splitting yourself, it's all in the docs.
Basically, your parameters are from the form itself and you just pull
them out by a statement like:

$client_name = $cgi->param(name);

for all your fields.

Now, I'm not exactly sure what you want to save, is it the filled-out
form with the user inputs in boxes exactly like the user would see them?
the filled-out form with the user inputs looking like they were part of
the form text? Whichever way, probably the easiest way I can think of to
save them is to print your form to a file as a "here document" putting
the variables in at the appropriate places, such as (just cobbled up on
the spot):

print FORM1 <<EndOfForm;
Content-type: text/html

<HTML><BODY>
Your name: $client_name <BR>
Your address: $client_address <P>

Your hobbies: $client_hobbies <P>
</BODY></HTML>
EndOfForm

Just take the HTML form and paste it into your Perl script, putting the
variables where they need to be (for checkboxes, pull-down menus, radio
buttons, you would put the values into the "Default = " part of the HTML
code). Now, my HTML syntax might be a little off, but I hope the idea
comes across. If you want just a plain text file with the user input in
it, then just leave out all the HTML stuff and format it as you want to.

If this is not what you want to do, please explain more.

Cameron

--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
[EMAIL PROTECTED]
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to