Category: >> Perl Code >> Getting Values Submitted From A Form Bookmark and Share

<< lastnext >>

Snippet Name: Getting Values Submitted From A Form

Description: This function parses the information submitted with the form, submitted with either method GET or method POST. The values are put in the FORM variable with hash names identical to the form field names. In other words, whatever is type into this form field

Also see:
» PHP Cron Parser Class
» Parse A URL Into Pieces
» Parse RSS into array

Comment: (none)

Author: CoderZone
Language: PERL
Highlight Mode: PERL
Last Modified: December 02nd, 2010

my %In = ();
sub Parse{
my $buffer;
$buffer = $ENV{QUERY_STRING}; 
read(STDIN,$buffer,$ENV{CONTENT_LENGTH}); }
my @p = split(/&/,$buffer);
$_ =~ tr/+/ /;
my ($n,$v) = split(/=/,$_,2);
$n =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$v =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
if($FORM{"$n"}) { $FORM{"$n"} .= "\t$v"; 
}else { $FORM{"$n"} = $v; }
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© | users online: 4