#!/usr/bin/perl # # example code for a cgi that submits a form to itself # decker/at/n3t.net $cgi_url = "http://www.n3t.net/Downloads/Code/sub.cgi"; if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/~!/ ~!/g; if (defined($FORM{$name})) { $FORM{$name} .= " : " . $value; } else { $FORM{$name} = $value; } } if($FORM{'action'} eq '') { print <Add Content
Add some content...

Content..


EOF ; exit; } elsif($FORM{'action'} eq 'doit') { $comments = $FORM{'comments'}; $kew = $FORM{'cool'}; print "Content-type: text/html\n\n"; print <Submitted Content Contents
$comments
is it $kew ?


EOF2 ; exit; }