#!/usr/bin/perl &Parse_Form; my $cname = $formdata{'cname'}; &Mime; print <

MYHTM exit; # Parses the form sub Parse_Form { 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); if ($ENV{'QUERY_STRING'}) { @getpairs = split(/&/, $ENV{'QUERY_STRING'}); push(@pairs, @getpairs); } } else { &ErrorMessage("Must use Post or Get."); } 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///g; if ($formdata{$key}) { $formdata{$key} .= ", $value"; } else { $formdata{$key} = $value; } } } # Standard little error message routine sub ErrorMessage { my $msg = shift; print "Content-type: text/html\n\n$msg"; exit; } # Prints the mime header only sub Mime { print "Content-type: text/html\nPragma: no-cache\n\n"; }