# Quick and dirty Web form processing script.  Emails the data
# to the recipient.

$recipient=@ARGV[0];
# Get the input and grok it into something legible

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
$postinput = $buffer;
$postinput =~ s/&/\n/g;
$postinput =~ s/\+/ /g;
$postinput =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig;

# print message to temporary file
$tempfile="formcontents.txt";
    open(OUTPUT, ">c:\\website\\formtext\\$tempfile") ||
 &error("Error writing to temporary file $tempfile");
 print OUTPUT $postinput;
    close OUTPUT;

# Now send mail to recipient
system "c:\\imail\\imail1.exe -f c:\\website\\formtext\\formcontents.txt -s Website Reply -t $recipient";

# Print out a content-type for HTTP/1.0 compatibility
print "Content-type:text/html\n\n";

# Print a title and initial heading
print "<Head><Title>Thank you</Title></Head>";
print "<Body><H2>Thanks for sending your comments!</H2>";

