#!/usr/bin/perl #=============== mailthanks.cgi =========== #Retrieves and parses form data, mails data & #displays thanks page #----------------- data --------------------- $mest = "
Your form output has been recorded."; $title = "We hear you!"; $dest = "jbotinov@idirect.com"; $subj = "Form Data"; #----------------- code --------------------- #:::: retrieve data by whatever method ::::: if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'}; } else { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); } #......... start a mail pipe ............... open (M,"|mail -s '$subj' $dest"); #......... convert special chrs ............ $in =~ s/\+/ /g; #change the +s to spaces $in =~ s/%([a-fA-F0-9][a-dA-F0-9])/pack(ìCî, hex($1))/eg; #change %3F to ? e.g. #........ make an array split on & ........ @in = split(/&/,$in); foreach (@in) { ($nam, $val) = split(/=/); print M "$nam: $val\n"; #format mail strings } print M "$ENV{'REMOTE_HOST'}\n"; # add userID close (M); #.......... now send the thanks page ........ &pagehead; print $mest; &pagetail; #---------------- sub-routines -------------- sub pagehead { print "Content-type: text/html\n\n", "\n
\n", "