[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Title: web/perl issue?
below is code I use to extract form data.
Only problem I'm having is that any data that comes in with
the form %xx from apache, doesn't seem to get converted
with substitution/pack command.
Any Ideas why?
George
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/,$ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer) ;
} else {
print "Content-type: text/html\n\n";
print "<HTML>";
print "<HEAD>";
print "<BODY>";
print "<CENTER>";
print "<H1>";
print "Use Post or Get";
print "</H1>";
print "</CENTER>";
print "</BODY>";
print "</HEAD>";
print "</HTML>";
goto eop;
}
foreach $pair (@pairs) {
($key, $value) = split (/=/, $pair) ;
$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;
$value =~ s/<!--(.|\n)*-->//g;
$formdata{$key} = $value;
}
$remoteip = $ENV{'REMOTE_ADDR'};
$evcode = $formdata{'EVCODEX'};
$evname = $formdata{'EVNAMEX'};
$evurl = $formdata{'EVURLX'};
$evamts = $formdata{'EVCHARGEX'};
open (HTTPOUT,"< $filename_in");
print "Content-type: text/html\n\n";
while (<HTTPOUT>) {
my $linein = $_;
chomp ($linein);
$linein=~ s/\#\#URL\#\#/$evurl/;
$linein=~ s/\#\#MNAME\#\#/$evname/;
$linein=~ s/\#\#MEVENTNO\#\#/$evcode/;
$linein=~ s/\#\#CHARGESCALE\#\#/$evamts/;
print "$linein\n";
}
George Gallen
Senior Programmer/Analyst
Accounting/Data Division
ggallen@slackinc.com
ph:856.848.1000 Ext 220
SLACK Incorporated - Delivering the best in health care information and education worldwide.
http://www.slackinc.com
___________________________________________________________________________
Philadelphia Linux Users Group -- http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|