#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
print "Content-type: text/html \n\n";

# Website Contact Form Generator 
# http://www.tele-pro.co.uk/scripts/contact_form/ 
# This script is free to use as long as you  
# retain the credit link  

# get posted data into local variables
$input = new CGI;
$EmailFrom = $input->param('EmailFrom'); 
$EmailTo = "Liteweydt\@hotmail.com";
$Subject = "Masonic Application";
$FirstName = $input->param('FirstName'); 
$LastName = $input->param('LastName'); 
$Address = $input->param('Address'); 
$Street1 = $input->param('Street1'); 
$PostCode = $input->param('PostCode'); 
$City = $input->param('City'); 
$State = $input->param('State'); 
$HomeTel = $input->param('HomeTel'); 
$WorkTel = $input->param('WorkTel'); 
$Mobile = $input->param('Mobile'); 

# validation
$validationOK=true;
if ($EmailFrom eq '') {$validationOK=false;}
if ($validationOK eq false) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

# prepare email body text
$Body .= "FirstName: ";
$Body .= "$FirstName";
$Body .= "\n";
$Body .= "LastName: ";
$Body .= "$LastName";
$Body .= "\n";
$Body .= "Address: ";
$Body .= "$Address";
$Body .= "\n";
$Body .= "Street1: ";
$Body .= "$Street1";
$Body .= "\n";
$Body .= "PostCode: ";
$Body .= "$PostCode";
$Body .= "\n";
$Body .= "City: ";
$Body .= "$City";
$Body .= "\n";
$Body .= "State: ";
$Body .= "$State";
$Body .= "\n";
$Body .= "HomeTel: ";
$Body .= "$HomeTel";
$Body .= "\n";
$Body .= "WorkTel: ";
$Body .= "$WorkTel";
$Body .= "\n";
$Body .= "Mobile: ";
$Body .= "$Mobile";
$Body .= "\n";

# send email 
use Win32::OLE;
$ex = Win32::OLE->new('CDONTS.NewMail') or die "\nCDONTS error";
$ex->Send($EmailFrom,$EmailTo,$Subject,$Body);

# redirect to success page 
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";