I can’t figure out why this won’t work and forms to go tech support non-existent. Please help! Thanks in advance
[php]<?PHP
######################################################
Forms To Go 4.5.4
http://www.bebosoft.com/
######################################################
define(‘kOptional’, true);
define(‘kMandatory’, false);
define(‘kStringRangeFrom’, 1);
define(‘kStringRangeTo’, 2);
define(‘kStringRangeBetween’, 3);
define(‘kYes’, ‘yes’);
define(‘kNo’, ‘no’);
define(‘kNumberRangeFrom’, 1);
define(‘kNumberRangeTo’, 2);
define(‘kNumberRangeBetween’, 3);
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 ProcessTextField(&$codeHtmlForm, $fieldName, $fieldValue) {
$tagPattern = ‘/(<input[^>]+name=[’"]?\Q’ . $fieldName . ‘\E[’"\s]+[^>]*>)/i’;
preg_match($tagPattern, $codeHtmlForm, $matches);
$htmlTag = $matches[1];
$valuePattern = ‘/value=[’"]?[^’"]*[’"]+/i’;
$replacementPattern = ‘value="’ . $fieldValue . '" ';
if (preg_match($valuePattern, $htmlTag)) {
$htmlTagToReplace = preg_replace($valuePattern, $replacementPattern, $htmlTag);
} else {
$valuePattern = ‘/([^>/]*)([/]?>)/’;
$replacementPattern = ‘\1 value="’ . $fieldValue . ‘" \2’;
$htmlTagToReplace = preg_replace($valuePattern, $replacementPattern, $htmlTag);
}
$codeHtmlForm = preg_replace($tagPattern, $htmlTagToReplace, $codeHtmlForm);
}
function ProcessPHPFile($PHPFile) {
ob_start();
if (file_exists($PHPFile)) {
require $PHPFile;
} else {
echo 'ErrorForms To Go - Error: Unable to load HTML form: ’ . $PHPFile . ‘’;
exit;
}
return ob_get_clean();
}
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 CheckNumeric($value, $low, $high, $mode, $optional) {
if ( (strlen($value) == 0) && ($optional === kOptional) ) {
return true;
} elseif (!is_numeric($value)) {
return false;
} elseif ( ($value >= $low) && ($mode == kNumberRangeFrom) ) {
return true;
} elseif ( ($value <= $high) && ($mode == kNumberRangeTo) ) {
return true;
} elseif ( ($value >= $low) && ($value <= $high) && ($mode == kNumberRangeBetween) ) {
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;
}
}
function CheckTelephone( $telephone, $valFormat, $optional ) {
if ( (strlen( $telephone ) == 0 ) && ( $optional === kOptional ) ) {
return true;
} elseif ( preg_match( $valFormat, $telephone ) == 1 ) {
return true;
} else {
return false;
}
}
if (isset($_SERVER[‘HTTP_X_FORWARDED_FOR’])) {
$clientIP = $_SERVER[‘HTTP_X_FORWARDED_FOR’];
} else {
$clientIP = $_SERVER[‘REMOTE_ADDR’];
}
$FTGqty = DoStripSlashes( $_POST[‘qty’] );
$FTGname = DoStripSlashes( $_POST[‘name’] );
$FTGaddress = DoStripSlashes( $_POST[‘address’] );
$FTGphone = DoStripSlashes( $_POST[‘phone’] );
$FTGemail = DoStripSlashes( $_POST[‘email’] );
$FTGseller = DoStripSlashes( $_POST[‘seller’] );
$FTGsecurity = DoStripSlashes( $_POST[‘security’] );
$FTGsubmit = DoStripSlashes( $_POST[‘submit’] );
$validationFailed = false;
Fields Validations
if (!CheckString($FTGqty, 1, 0, kStringRangeFrom, kNo, kNo, kNo, ‘’, kMandatory)) {
$FTGErrorMessage[‘qty’] = ‘Please enter the ticket quantity.’;
$validationFailed = true;
}
if (!CheckString($FTGname, 1, 0, kStringRangeFrom, kNo, kNo, kNo, ‘’, kMandatory)) {
$FTGErrorMessage[‘name’] = ‘Please enter your name.’;
$validationFailed = true;
}
if (!CheckString($FTGaddress, 1, 0, kStringRangeFrom, kNo, kNo, kNo, ‘’, kMandatory)) {
$FTGErrorMessage[‘address’] = ‘Please enter your address.’;
$validationFailed = true;
}
if (!CheckTelephone($FTGphone, ‘/[0-9]{3}-[0-9]{3}-[0-9]{4}/’, kMandatory)) {
$FTGErrorMessage[‘phone’] = ‘Please enter your 10-digit phone number.’;
$validationFailed = true;
}
if (!CheckEmail($FTGemail, kMandatory)) {
$FTGErrorMessage[‘email’] = ‘Please enter a valid email address.’;
$validationFailed = true;
}
if (!CheckNumeric($FTGsecurity, 6, 6, kNumberRangeBetween, kMandatory)) {
$FTGErrorMessage[‘security’] = 'Please enter the number 6. ';
$validationFailed = true;
}
Display HTML form with filled values
if ($validationFailed === true) {
$fileHtmlForm = ‘…/kulanukids.org/500_raffle.php’;
$codeHtmlForm = ProcessPHPFile($fileHtmlForm);
ProcessTextField($codeHtmlForm, ‘qty’, $FTGqty);
ProcessTextField($codeHtmlForm, ‘name’, $FTGname);
ProcessTextField($codeHtmlForm, ‘address’, $FTGaddress);
ProcessTextField($codeHtmlForm, ‘phone’, $FTGphone);
ProcessTextField($codeHtmlForm, ‘email’, $FTGemail);
ProcessTextField($codeHtmlForm, ‘seller’, $FTGseller);
ProcessTextField($codeHtmlForm, ‘security’, $FTGsecurity);
$errorList = @implode("
\n", $FTGErrorMessage);
$codeHtmlForm = str_replace(’’, $errorList, $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGqty, $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGname, $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGaddress, $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGphone, $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGemail, $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGseller, $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGsecurity, $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGsubmit, $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGErrorMessage[‘qty’], $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGErrorMessage[‘name’], $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGErrorMessage[‘address’], $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGErrorMessage[‘phone’], $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGErrorMessage[‘email’], $codeHtmlForm);
$codeHtmlForm = str_replace(’’, $FTGErrorMessage[‘security’], $codeHtmlForm);
if (count( array_filter( $FTGErrorMessage ) ) > 0 ) {
foreach( $FTGErrorMessage as $key => $message ) {
$ErrorMessage .= trim( str_replace("’", “’”, $message ) ) . ‘\n’;
}
$alertJSErrorMessage = “window.alert(’” . $ErrorMessage . “’);”;
$onloadPattern = ‘/(<body[^>]+onload=["])"([^>])>/i’;
if ( preg_match( $onloadPattern, $codeHtmlForm ) ) {
$replacementPattern = ‘\1"’ . $alertJSErrorMessage . ‘\2>’;
} else {
$onloadPattern = ‘/(<body[^>]*)>/i’;
$replacementPattern = ‘\1 onload="’ . $alertJSErrorMessage . ‘">’;
}
$codeHtmlForm = preg_replace( $onloadPattern, $replacementPattern, $codeHtmlForm);
}
echo $codeHtmlForm;
}
if ( $validationFailed === false ) {
Email to Form Owner
$emailSubject = FilterCChars(“Raffle Tickets”);
$emailBody = “qty : $FTGqty\n”
. “\n”
. “name : $FTGname\n”
. “\n”
. “address : $FTGaddress\n”
. “\n”
. “phone : $FTGphone\n”
. “\n”
. “email : $FTGemail\n”
. “\n”
. “seller : $FTGseller\n”
. “\n”
. “”;
$emailTo = ‘Denise Perciballi [email protected],Rachael Habermann-Berg [email protected],Miriam Steinberg [email protected]’;
$emailFrom = FilterCChars("[email protected]");
$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);
Redirect user to success page
header(“Location: http://www.kulanukids.org/raffle_thanks.html”);
}
?>[/php]