Get Form Post
2002-01-20 20:01:44
Category: perl:cgi
Description: Get data from a form using the post option.
Author: detour
Viewed: 3441
Rating: (11 votes)


#!/usr/bin/perl
#
# getpost.cgi written by detour@metalshell.com
#
# Get data from a form using the post option
# 
# http://www.metalshell.com/
#
 
print "Content-type: text/html \n\n";
print "<html><body>";
 
# Get the posted string and seperate the key=value
read(STDIN, $qstring, $ENV{'CONTENT_LENGTH'});
@key_value = split(/&/, $qstring);
 
foreach $pair (@key_value) {
  $pair =~ tr/+/ /;
  ($key, $value) = split(/=/, $pair);
 
  # Convert the % codes too Ascii
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  
  print "$key = $value";
}
 
print "</body></html>";