<?php
# ----------------------------------------------------
# -----
# ----- This script was generated by PHP-Form Wizard 1.2.5 on 10/8/2008 at 4:51:26 PM
# -----
# ----- http://www.tools4php.com
# -----
# ----------------------------------------------------


// Receiving variables
@$pfw_ip= $_SERVER['REMOTE_ADDR'];
@$Name = addslashes($_GET['Name']);
@$Co_Name = addslashes($_GET['Co_Name']);
@$Tel._Number = addslashes($_GET['Tel._Number']);
@$email_address_ = addslashes($_GET['email_address_']);

// Validation
if (strlen($Name) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid name</font></p>");
}

if (strlen($Co_Name) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter your company name</font></p>");
}

if (strlen($Tel._Number) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter your telephone number</font></p>");
}

if (strlen($email_address_) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter your email address</font></p>");
}

//Sending Email to form owner
$pfw_header = "From: contact_email\n"
  . "Reply-To: contact_email\n";
$pfw_subject = "Brilliant Loans and Brilliant Solutions Newsletter";
$pfw_email_to = "brillnews@premiergroup.efhmail.com";
$pfw_message = "Visitor's IP: $pfw_ip\n"
. "Name: $Name\n"
. "Co_Name: $Co_Name\n"
. "Tel._Number: $Tel._Number\n"
. "email_address_: $email_address_\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

//Sending auto respond Email to visitor
$pfw_header = "From: brillnews@premiergroup.efhmail.com\n"
  . "Reply-To: brillnews@premiergroup.efhmail.com\n";
$pfw_subject = "Brilliant Loans and Brilliant Solutions Newsletter";
$pfw_email_to = "$contact_email";
$pfw_message = "Thank you for subscribing to the Brilliant Newsletter.  You have been added to our subscribers list and you will receive our latest newsletter by email shortly.  If at any time you want to unsubscribe all you need to do is to click on the unsubscribe button on the newsletter.\n"
. "\n"
. "Thank you\n"
. "\n"
. "\n"
. "Brilliant Solutions";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

//saving record in a text file
$pfw_file_name = "newsletterlog.csv";
$pfw_first_raw = "Name,Co_Name,Tel._Number,email_address_\r\n";
$pfw_values = "$Name,$Co_Name,$Tel._Number,$email_address_\r\n";
$pfw_is_first_row = false;
if(!file_exists($pfw_file_name))
{
 $pfw_is_first_row = true ;
}
if (!$pfw_handle = fopen($pfw_file_name, 'a+')) {
 die("Cannot open file ($pfw_file_name)");
 exit;
}
if ($pfw_is_first_row)
{
  if (fwrite($pfw_handle, $pfw_first_raw ) === FALSE) {
  die("Cannot write to file ($pfw_filename)");
  exit;
  }
}
if (fwrite($pfw_handle, $pfw_values) === FALSE) {
  die("Cannot write to file ($pfw_filename)");
  exit;
}
fclose($pfw_handle);

 echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>The form was successfully submitted, you will will get an email from us shortly.</font></p>");
?>
