Economic Research
Strategy Directorate
CELTEC
Unit 6
St. Asaph Business Park
St. Asaph
Denbighshire
LL17 0LJ
01745 538546 (Direct)
01745 538500 (Switchboard)
www.celtec.co.uk
www.nwalesleo.org
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 07 November 2000 14:26
To: [EMAIL PROTECTED]
Subject: Emailing forms w/data intactCan 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.
---- Begin Perl ----
@query=split(/&/,$ENV{'QUERY_STRING'});
foreach $pair (@query) {
($key,$value)=split(/=/,$pair);
$key =~ tr/A-Z/a-z/;
$key =~ tr/+/ /;
$key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$query{$key}=$value;
}read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $input);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<([^>]|\n)*>//g;
$form{$name}=$value;
}if (%form) {
restore_parameters(STDIN);
open(FORM,"$query{'form'}");
$separator=$/;
undef $/;
$query=new CGI(FORM);
close(FORM);open(OUT,">test.html");
$query->save(OUT);
close(OUT);
print "Done.";
$/=$separator;
exit;
}print "query(form): $query{'form'}<br>\n";
$separator=$/;
undef $/;
open(FORM,"$query{'form'}");
$form=<FORM>;
close(FORM);
print "form: $form<br>\n";
$/=$separator;
---- End Perl ----Any suggestions?
TIA.
Ymwadiad Ebost
Ar gyfer y derbynwyr a enwir yn unig y mae'r trosglwyddiad ebost hwn. Gallai gynnwys gwybodaeth breifat a chyfrinachol. Os nad chi yw'r derbyniwr bwriadedig neu'r person sy'n gyfrifol am ddanfon i'r derbyniwr arfaethedig, rhaid i chi beidio � chymryd camau gweithredu'n seiliedig arno, na'i gop�o na'i ddangos i unrhyw berson; byddwch cystal � chysylltu � [EMAIL PROTECTED] ar unwaith os derbyniwch y neges hon trwy gamgymeriad. Ni allwn dderbyn unrhyw gyfrifoldeb dros unrhyw golled neu niwed sy'n digwydd o ganlyniad i firysau meddalwedd.
E mail Disclaimer
This electronic mail transmission is intended for the named recipients only. It may contain private and confidential information If you are not the intended recipient or the person responsible for delivering to the intended recipient, you must take no action based upon it, nor must you copy it or show it to anyone; please contact [EMAIL PROTECTED] immediately if you have received this message by mistake. We cannot accept any liability for any loss or damage sustained as a result of software viruses.
