Please help by telling me how to add a BCC email into this code. that emails the form to the BCC person.
[php]
define(‘kOptional’, true);
define(‘kMandatory’, false);
define(‘kStringRangeFrom’, 1);
define(‘kStringRangeTo’, 2);
define(‘kStringRangeBetween’, 3);
define(‘kYes’, ‘yes’);
define(‘kNo’, ‘no’);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set(‘track_errors’, true);
function DoStripSlashes($fieldValue) {
// temporary fix for PHP6 compatibility - magic quotes deprecated in PHP6
if ( function_exists( ‘get_magic_quotes_gpc’ ) && get_magic_quotes_gpc() ) {
if (is_array($fieldValue) ) {
return array_map(‘DoStripSlashes’, $fieldValue);
} else {
return trim(stripslashes($fieldValue));
}
} else {
return $fieldValue;
}
}
function FilterCChars($theString) {
return preg_replace(’/[\x00-\x1F]/’, ‘’, $theString);
}
function CheckString($value, $low, $high, $mode, $limitAlpha, $limitNumbers, $limitEmptySpaces, $limitExtraChars, $optional) {
$regEx = ‘’;
if ($limitAlpha == kYes) {
$regExp = ‘A-Za-z’;
}
if ($limitNumbers == kYes) {
$regExp .= ‘0-9’;
}
if ($limitEmptySpaces == kYes) {
$regExp .= ’ ';
}
if (strlen($limitExtraChars) > 0) {
$search = array(’\’, ‘[’, ‘]’, ‘-’, ‘$’, ‘.’, ‘*’, ‘(’, ‘)’, ‘?’, ‘+’, ‘^’, ‘{’, ‘}’, ‘|’, ‘/’);
$replace = array(’\\’, ‘[’, ‘]’, ‘-’, ‘$’, ‘.’, ‘*’, ‘(’, ‘)’, ‘?’, ‘+’, ‘^’, ‘{’, ‘}’, ‘|’, ‘/’);
$regExp .= str_replace($search, $replace, $limitExtraChars);
}
if ( (strlen($regExp) > 0) && (strlen($value) > 0) ){
if (preg_match(’/[^’ . $regExp . ‘]/’, $value)) {
return false;
}
}
if ( (strlen($value) == 0) && ($optional === kOptional) ) {
return true;
} elseif ( (strlen($value) >= $low) && ($mode == kStringRangeFrom) ) {
return true;
} elseif ( (strlen($value) <= $high) && ($mode == kStringRangeTo) ) {
return true;
} elseif ( (strlen($value) >= $low) && (strlen($value) <= $high) && ($mode == kStringRangeBetween) ) {
return true;
} else {
return false;
}
}
function CheckEmail($email, $optional) {
if ( (strlen($email) == 0) && ($optional === kOptional) ) {
return true;
} elseif ( preg_match("/^([\w!#$%&’*+-/=?^`{|}~]+.)*[\w!#$%&’*+-/=?^`{|}~]+@((((([a-z0-9]{1}[a-z0-9-]{0,62}[a-z0-9]{1})|[a-z]).)+[a-z]{2,6})|(\d{1,3}.){3}\d{1,3}(:\d{1,5})?)$/i", $email) == 1 ) {
return true;
} else {
return false;
}
}
if (isset($_SERVER[‘HTTP_X_FORWARDED_FOR’])) {
$clientIP = $_SERVER[‘HTTP_X_FORWARDED_FOR’];
} else {
$clientIP = $_SERVER[‘REMOTE_ADDR’];
}
$FTGCOMMENT = DoStripSlashes( $_POST[‘COMMENT’] );
$FTGNAME = DoStripSlashes( $_POST[‘NAME’] );
$FTGEMAIL = DoStripSlashes( $_POST[‘EMAIL’] );
$validationFailed = false;
Fields Validations
if (!CheckString($FTGCOMMENT, 3, 2000, kStringRangeBetween, kNo, kNo, kNo, ‘’, kMandatory)) {
$FTGErrorMessage[‘COMMENT’] = ‘’;
$validationFailed = true;
}
if (!CheckString($FTGNAME, 3, 30, kStringRangeBetween, kNo, kNo, kNo, ‘’, kMandatory)) {
$FTGErrorMessage[‘NAME’] = ‘’;
$validationFailed = true;
}
if (!CheckEmail($FTGEMAIL, kMandatory)) {
$FTGErrorMessage[‘EMAIL’] = ‘Enter email’;
$validationFailed = true;
}
Include message in error page and dump it to the browser
if ($validationFailed === true) {
$errorPage = 'ErrorErrors found: ';
$errorList = @implode("
\n", $FTGErrorMessage);
$errorPage = str_replace(’’, $errorList, $errorPage);
echo $errorPage;
}
if ( $validationFailed === false ) {
Email to Form Owner
$emailSubject = FilterCChars(“Form from xxxxxxxxxxxxxx”);
$emailBody = “NAME : $FTGNAME\n”
. “EMAIL : $FTGEMAIL\n”
.“COMMENT : $FTGCOMMENT\n”;
$emailTo = ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’;
$emailFrom = FilterCChars("$FTGEMAIL");
$emailHeader = “From: $emailFrom\n”
. “MIME-Version: 1.0\n”
. “Content-type: text/plain; charset=“UTF-8”\n”
. “Content-transfer-encoding: 8bit\n”;
mail($emailTo, $emailSubject, $emailBody, $emailHeader);
Include message in the success page and dump it to the browser
$successPage = ‘SuccessForm submitted successfully. It will be reviewed soon.’;
echo $successPage;
}
?>[/php]
Many thanks