Why would he need to do all that? Assuming he uses CGI.pm to generate the
form, he can simply print out the form fields or the result if it exists.

Something along the lines of:
        if (param()) {
                print param('name');                # print response
        } else {
                print textfield(-name=>'name' ...); # print form field
        }

or, more simply,
        print param()? param('name') : textfield(-name=>'name');

and if you wanted to only print the non-blank responses:
        print param('name') || textfield(-name=>'name');

--
Mark Thomas                    [EMAIL PROTECTED]
Sr. Internet Architect         User Technology Associates, Inc.

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;;

-----Original Message-----
From: Jonathan Crowther [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 07, 2000 7:14 PM
To: [EMAIL PROTECTED]; '[EMAIL PROTECTED]'
Subject: RE: Emailing forms w/data intact


Given that you already have the HTML files, and you need to scan them for
the form tags that you want to replace with the values submitted, you could
also look at using the HTML parser to scan the HTML tags, such as the
following:
HTML::TreeBuilder 
HTML::Parser 
HTML::TokeParser 
HTML::Form 
HTML::Element 
I have never used these myself, but they look useful in your case. 
The methodology would be: 
1. Use CGI.pm to read the query (including for form name and key/value
pairs) 
2. Use HTML::TreeBuilder to scan the HTML page 
3. Replace Form elements with values entered (in 1.) using 
4. Use CGI.pm and also "print $h->as_HTML" to print the HTML elements out 
5. Use Net::SMTP to send the e-mail 
Looking at this again, you may want to go with HTML::TokeParser instead of
HTML::TreeBuilder.... any way, you can continue looking...
Cheers, 
Jonathan 
"Joust Not with Dragons, for Thou art Crunchy, and Goode with Ketchup..." 


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


> [EMAIL PROTECTED] wrote: 
> 
> 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. 
See below, that's how I would do it. Just read your HTML file into a 
filehandle and stick the user inputs into it, then print back out. I was 
just suggesting (strongly) that as long as you are using CGI.pm (and I 
would always use CGI.pm), use it effectively, let it do the 
packing/unpacking/splitting/tr'ing, don't reinvent the wheel. 
Cameron 
> -----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 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 
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to