#!/usr/bin/perl &get_form_data(); &send_email; &print_thankyou_page; sub get_form_data { # Get the input read(STDIN, $buffer, $ENV{ 'CONTENT_LENGTH' } ); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; $FORM{$name} = $value; } } sub send_email { $to = "maegan\@siena.edu"; open(MAIL, "|/usr/sbin/sendmail -t $to") || die ("can't open sendmail"); print MAIL "From: $FORM{'email'}\n"; print MAIL "To: $to\n"; print MAIL "Subject: Form submission\n\n"; # print out the form results print MAIL "Name: $FORM{'name'}\n"; print MAIL "Company: $FORM{'company'}\n"; print MAIL "Address: $FORM{'address1'}\n"; print MAIL "City: $FORM{'city'}\n"; print MAIL "State: $FORM{'state'}\n"; print MAIL "Country: $FORM{'country'}\n"; print MAIL "Telephone: $FORM{'telephone'}\n"; print MAIL "Fax: $FORM{'fax'}\n"; print MAIL "E-mail: $FORM{'email'}\n"; print MAIL "Services interested in: $FORM{'services'}\n"; print MAIL "Notified when pages updated: $FORM{'notify'}\n"; print MAIL "Comments: $FORM{'comments'}\n"; close(MAIL); } sub print_thankyou_page { print "Content-type: text/html\n\n"; print "\n\n"; print "

\n"; exit print "Thank you\n"; print "

\n\n"; print "Thank you for your submission\n "; print "\n

\n"; print "\n
"; }