	"Lisa U. Thompson" <lthompso@census.gov>
	Sent by: lthompso@census.gov
	06/24/2002 12:51 PM
		 
		 To: cassandra.h.thomas@census.gov
		 cc: 
		 Subject: Email to collect Form Data


Hello,

This is a sample perl script that creates a form and emails the
information collected.

#!/usr/bin/perl

#-------------------
#Script: getdata
#-------------------

use CGI qw(:standard :html);
use Mail::Mailer;

$action = $ENV{'QUERY_STRING'};
$script = script_name;

if ($action eq 'mail') {
   &sendmail;
}
else {
  &showform;
}

sub showform {
   print header;
   print start_html(-title=>'Collect data',-bgcolor=>'#FFFFFF'),
            start_form(-action=>"$script?mail"),
                "Name:
",textfield(-name=>'Name',-size=>30,-maxlength=>70),br,
                "Phone Number:
",textfield(-name=>'number',-size=>13,-maxlength=>13),
                "E-Mail Address:
",textfield(-name=>'email',-size=>40,-maxlength=>80),
             end_form;
}

sub sendmail {
    $recipient = "cassandra.h.thomas@census.gov;
    $subject = "Requested Information";
    $name = param('Name');
    $number = param('number');
    $email = param('email');
    $mailer = Mail::Mailer->new("sendmail");
    $mailer->open({ To      => $recipient,
                               From    => $email,
                               Subject => $subject
                    })
                   or die "Can't open: $!\n";
    print $mailer "This is the data requested:\n",
                          "Name:  $name\n",
                          "Phone Number:  $number\n",
                          "E-Mail Address:  $email\n";
}




