Save As in your // browser menu and choose the file name ( should end with .php ) // -------------------------------------------------------------- // Warning: Please do not modify the PHP code of this form, unless // you know what you do. // Form data names and variables $FName = 'Register'; $FEmail = 'Jingshan Tang , '; $FSpamEmail = ''; $FWebsiteAfter = 'http://'; $FCopyToSender = 0; $FExporting = 0; $FDMode = 1; $FMesFromT = 1; $FMesName = 0; $FMesFrom = 1; $FMesSubjectT = 2; $FMesSubject = 2; $FCopyToSender = 0; $FExporting = 0; $FieldsNo = 8; $FieldName[0] = 'Your Name'; $FieldType[0] = 1; $FieldTypeExt[0] = ''; $FieldCols[0] = 30; $FieldRows[0] = 0; $FieldS[0] = ''; $FieldRequired[0] = 1; $FieldName[1] = 'Your Email Address'; $FieldType[1] = 1; $FieldTypeExt[1] = ''; $FieldCols[1] = 30; $FieldRows[1] = 0; $FieldS[1] = ''; $FieldRequired[1] = 1; $FieldName[2] = 'Phone Number'; $FieldType[2] = 1; $FieldTypeExt[2] = ''; $FieldCols[2] = 30; $FieldRows[2] = 0; $FieldS[2] = ''; $FieldRequired[2] = 0; $FieldName[3] = 'Select Class to register'; $FieldType[3] = 3; $FieldTypeExt[3] = 'Tai Chi | Qi Gon Gong | Tai Chi Workshop | Qi Gong Workshop | Other( Please describe ) '; $FieldCols[3] = 0; $FieldRows[3] = 0; $FieldS[3] = ''; $FieldRequired[3] = 1; $FieldName[4] = 'Select Class Date'; $FieldType[4] = 3; $FieldTypeExt[4] = 'Sun. | Mon.| Tus. Wed. | Thur. | Fir. | Sat. '; $FieldCols[4] = 0; $FieldRows[4] = 0; $FieldS[4] = ''; $FieldRequired[4] = 1; $FieldName[5] = 'Select Class Time'; $FieldType[5] = 3; $FieldTypeExt[5] = 'Morning9:00-12:00 | Afternoon 12:-6:00 | Evening 6:00-9:00 '; $FieldCols[5] = 0; $FieldRows[5] = 0; $FieldS[5] = ''; $FieldRequired[5] = 1; $FieldName[6] = ' Goal of learning'; $FieldType[6] = 3; $FieldTypeExt[6] = 'For Health Care | self defense | for habit'; $FieldCols[6] = 0; $FieldRows[6] = 0; $FieldS[6] = ''; $FieldRequired[6] = 1; $FieldName[7] = 'Eexperience and commend. '; $FieldType[7] = 2; $FieldTypeExt[7] = ''; $FieldCols[7] = 60; $FieldRows[7] = 10; $FieldS[7] = ''; $FieldRequired[7] = 0; // Error Messages $HtmlErrorStart = ''; $HtmlErrorEnd = ''; $msgErrorTooLongs = ' is too long! (Max '; $msgErrorTooLonge = ' characters)'; $msgErrorTooShorts = ' is too short! (Min '; $msgErrorTooShorte = ' characters)'; $msgErrorFieldEmpty = ' is empty! ( This field is required )'; $msgError = 'Error : '; $msgErrorBadFields = 'Some fields are empty or invalid.'; // Needed functions // -------------------------------------------------------------- function checkminsize($input, $min) // Check a string size { if (strlen($input)<$min) return 0; else return 1; } // -------------------------------------------------------------- function checkmaxsize($input, $max) // Check a string size { if (strlen($input)>$max) return 0; else return 1; } // -------------------------------------------------------------- function CheckTextSize($text, $min, $max, $errno, $errfieldname) { global $mmsg, $verifyok, $HtmlErrorStart, $HtmlErrorEnd, $msgErrorTooLongs, $msgErrorTooLonge, $msgErrorTooShorts, $msgErrorTooShorte, $msgErrorFieldEmpty, $mmsgt, $msgError, $msgErrorBadFields; if (!checkminsize($text,$min)) { $mmsg[$errno] = $HtmlErrorStart . $errfieldname . $msgErrorTooShorts . $min . $msgErrorTooShorte . $HtmlErrorEnd; $verifyok = 0; } if (!checkmaxsize($text,$max)) { $mmsg[$errno] = $HtmlErrorStart . $errfieldname . $msgErrorTooLongs . $max . $msgErrorTooLonge . $HtmlErrorEnd; $verifyok = 0; } if ($min>0) if (!checkminsize($text,1)) { $mmsg[$errno] = $HtmlErrorStart . $errfieldname . $msgErrorFieldEmpty . $HtmlErrorEnd; $verifyok = 0; } if ($verifyok == 0 ) { $mmsg[0] = $msgError . $msgErrorBadFields; $mmsgt = 1; } return $verifyok; } // -------------------------------------------------------------- function SecurityCheckCode($Turing) { global $ImageCode; if ( !isset( $_SESSION['turing_string'] ) ) { $ImageCode = ''; return 1; } else if ( strtoupper($_SESSION['turing_string']) == strtoupper($Turing) ) { $ImageCode = 'ok'; return 1; } else { $ImageCode = 'wrong'; return 0; } } // -------------------------------------------------------------- function getip() // Returns the real Ip in most cases { if (isSet($_SERVER)) { if (isSet($_SERVER["HTTP_X_FORWARDED_FOR"])) { $realip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } elseif (isSet($_SERVER["HTTP_CLIENT_IP"])) { $realip = $_SERVER["HTTP_CLIENT_IP"]; } else { $realip = $_SERVER["REMOTE_ADDR"]; } } else { if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) { $realip = getenv( 'HTTP_X_FORWARDED_FOR' ); } elseif ( getenv( 'HTTP_CLIENT_IP' ) ) { $realip = getenv( 'HTTP_CLIENT_IP' ); } else { $realip = getenv( 'REMOTE_ADDR' ); } } return $realip; } // Processing form // -------------------------------------------------------------- session_start(); $RealIp = getip(); if ( $_SESSION['FReferer'] == '' ) { $R = @$_SERVER['HTTP_REFERER']; if ( R != '' ) $_SESSION['FReferer'] = $R; } $Referer = $_SESSION['FReferer']; // ------------------------------------------------------------------------------------- function CheckEmail($email,$minsize,$maxsize,$err,$fieldname) { global $mmsg, $mmsgt, $HtmlErrorStart, $HtmlErrorEnd, $verifyok; // check if the email string is not empty, has at least 4 chars, is smaller than 64 CheckTextSize($email, $minsize, $maxsize, $err, $fieldname); if ( ($minsize == 0 ) AND ( $email == '') ) return 0; // check if is has a valid email format xxx@yyy.domainname if ( ! (valid_email($email)) ) {$mmsg[$err] = $HtmlErrorStart . 'Email does not appear to be valid' . $HtmlErrorEnd; $mmsgt = 1; $verifyok = 0; return 1;} // check if the email string contains more than 1 email if ( substr_count($FEmail, '@') > 1 ) {$mmsg[$err] = $HtmlErrorStart . 'Only one email is allowed' . $HtmlErrorEnd; $mmsgt = 1; $verifyok = 0;}; } // ------------------------------------------------------------------------------------- function valid_email($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } // Get form settings and fields for ($i=0;$i<$FieldsNo;$i++) { if ( $FieldType[$i] ==3 ) { // checkbox $FieldData[$i] = ''; $Options = explode('|', $FieldTypeExt[$i]); $OptionsNo = count($Options); for ($j=0;$j<$OptionsNo;$j++) { $fd = trim($_POST['FieldData' . $i . '-' . $j]); $FieldData[$i] .= $fd; if ( ($j<($OptionsNo-1)) and ( $fd !='' ) ) $FieldData[$i] .= ', '; } } else $FieldData[$i] = trim($_POST['FieldData' . $i]); } if ( $HTTP_POST_VARS ) { // Basic verifications of the form submitted, check if the version is ok // and the fields number corsesponds if ($FieldsNo <> count($FieldData)) { echo 'Error: The number of submitted data fields ( ' . count($FieldData) . ' ) does not corespond to the form ( ' . $FName . ' wich has ' . $FieldsNo . ' fields ).'; return 3; } $Hida2 = trim($_POST['hida2']); if ($Hida2 != '') { echo 'Error: Spam submission detected ).'; return 4; } $mmsgt = 0; $verifyok = 1; $SpamScore = 0; $DupFields = 0; $Spam = 0; $Hida2 = trim($_POST['hida2']); if ($Hida2 != '') { $mmsg[0] = $HtmlErrorStart . 'Error: Your submission is spam.' . $HtmlErrorEnd; $mmsgt = 1; $Spam = 1; } $SpamWord = array( 'http', 'URL', 'cialis', 'viagra', 'xxx', 'valium'); for ($i=0;$i<$FieldsNo;$i++) if ($FieldType[$i]<6) { if ($FieldRequired[$i] == 1) { CheckTextSize($FieldData[$i], 1, 10000, ($i+1), $FieldName[$i]); if ( ($FMesFromT ==2) && ( $FMesFrom == $i ) ) CheckEmail($FieldData[$FMesFrom], 4, 64, ($i+1), $FieldName[$i]); } for ($j=0;$j 10) { $mmsg[0] = $HtmlErrorStart . 'Error: Your submission is spam.' . $HtmlErrorEnd; $mmsgt = 1; $Spam = 2; } // Check if the Turing Code is correct $Turing = trim($_POST['Turing']); if ( ! ( SecurityCheckCode($Turing)) ) { $mmsg[0] = $HtmlErrorStart . 'Error: The Code that you entered is not the correct code from the Verification Image!' . $HtmlErrorEnd; $mmsgt = 1; $Spam = 4; } // check for new lines in inapropiate places // check for new lines in the From name and email if ($FMesFromT ==2) if (preg_match("/(%0A|%0D|\\n+|\\r+)/i",$FieldData[$FMesName] . $FieldData[$FMesFrom])) $FMesFromT = 1; // check for new lines in the Subject if ($FMesSubjectT ==2) if (preg_match("/(%0A|%0D|\\n+|\\r+)/i",$FieldData[$FMesSubject])) $FMesSubjectT = 1; if ( ($mmsgt !=1) or ($Spam > 0 ) ) { $mime_boundary=md5(time()); // Prepare email $headers = ""; if ($Spam == 0) { if ($FMesFromT ==1) $fromaddress = "EmailMeForm "; elseif ($FMesFromT ==2) { $CustomerName = $FieldData[$FMesName]; $CustomerEmail = $FieldData[$FMesFrom]; $fromaddress = "$CustomerName "; } $headers .= "From: $fromaddress\r\n"; $headers .= "Reply-To: $FieldData[$FMesName] <$FieldData[$FMesFrom]>\r\n"; } else $headers .= "From: EmailMeForm \r\n"; $subject = 'Feedback via the ' . $FName; if ($FMesSubjectT ==2) $subject = $FName . ': ' . $FieldData[$FMesSubject]; if ($Spam > 0) $subject = $FName . ' Spam submission detected'; $headers .= "Message-ID: <".time()."-@blueplaza.net>\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary. '"' . "\r\n\r\n"; $body = "--".$mime_boundary. "\r\n"; $body .= "Content-Type: text/plain; charset=\"utf-8\"\r\n"; $body .= "Content-Transfer-Encoding: 8bit\r\n\r\n"; if ($Spam > 0) { $body .= " The following submission has been detected as spam.\r\n"; $body .= ' Spam type: '; switch ($Spam) { case 1 : $body .= "Bad hidden field\r\n\r\n"; break; case 2 : $body .= "Bad words detected\r\n\r\n"; break; case 3 : $body .= "Same data was filled in more than half fields\r\n\r\n"; break; case 4 : $body .= "Bad or invalid captcha code\r\n\r\n"; break; case 5 : $body .= "Unknown Ip\r\n\r\n"; break; case 6 : $body .= "Injection attack\r\n\r\n"; break; case 7 : $body .= "Injection attack\r\n\r\n"; break; } } for ($i=0;$i<$FieldsNo;$i++) if ($FieldType[$i]<6) $body .= $FieldName[$i] . ': ' . $FieldData[$i] . "\r\n"; $body .= "---------------------------------------------------------------------\r\n"; $body .= 'Visitor Ip: ' . $RealIp . "\r\n"; if ($FExporting == 1) { $body .= "*** Text Database Entry ***\r\n"; for ($i=0;$i<($FieldsNo-1);$i++) $body .= '"' . $FieldName[$i] . '",'; $body .= '"' . $FieldName[$FieldsNo-1] . '"' . "\r\n"; for ($i=0;$i<($FieldsNo-1);$i++) $body .= '"' . $FieldData[$i] . '",'; $body .= '"' . $FieldData[$FieldsNo-1] . '"' . "\r\n"; } // Adding attachments for($i=0; $i<$FieldsNo; $i++) if ($FieldType[$i] == 6) { $fd = 'FieldData' . $i; if (is_uploaded_file($_FILES["$fd"][tmp_name])) { $handle=fopen($_FILES["$fd"][tmp_name], 'rb'); $f_contents=fread($handle, filesize($_FILES["$fd"][tmp_name])); $f_contents=chunk_split(base64_encode($f_contents)); $f_type=filetype($_FILES["$fd"][tmp_name]); fclose($handle); # Attachment $filename = $_FILES["$fd"][name]; $body .= "--".$mime_boundary."\r\n"; $body .= 'Content-Type: ' . $_FILES["$fd"][type] . '; name="' . $filename . '"' . "\r\n"; $body .= "Content-Transfer-Encoding: base64\r\n"; $body .= "Content-Description: $FieldName[$i]\r\n"; $body .= 'Content-Disposition: attachment; filename="' . $filename . '"'."\r\n\r\n"; $body .= $f_contents."\r\n\r\n"; } } # Finished $body .= "--".$mime_boundary."--\r\n\r\n"; // finish with two eol's for better security. see Injection. if ($Spam == 0) { // We try to send the email with verification code if (mail("$FEmail", $subject, $body, $headers) ) if ( $SaveEmails == 1) { // The mail has been sent succesfuly, update the email table $query="UPDATE email SET Status='delivered', DateDelivered = NOW() WHERE EmailId='$EmailId'"; mysql_query($query) or die(mysql_error()); } } else if ($FSpamEmail != '') @mail("$FSpamEmail", $subject, $body, $headers); // If Sending a copy to visitor is checked and the field from where to get the visitor email // address is selected we send a copy to the visitor if ( ($FCopyToSender == 1) && ($FMesFromT ==2) AND ($Spam == 0) ) { $headers = "From: $FFirstName $FLastName \r\n"; $headers = "Reply-to: $FFirstName $FLastName <$FEmail>\r\n"; $subject = 'We have received your email'; if ($FMesSubjectT ==2) $subject .= ': ' . $FieldData[$FMesSubject]; $body = 'Hello ' . $FieldData[$FMesName] . ",\r\n \r\n"; $body .= "We have received your form submission, thank you!\r\n \r\n"; $body .= "Below is the data submitted:\r\n \r\n"; for ($i=0;$i<$FieldsNo;$i++) if ( $FieldType[$i] <6 ) $body .= $FieldName[$i] . ' : ' . $FieldData[$i] . "\r\n"; $body .= "\r\nBest regards,\r\n"; $body .= "$FFirstName $FLastName\r\n"; // We try to send the email with verification code @mail("$FieldData[$FMesName] <$FieldData[$FMesFrom]>", $subject, $body, $headers); } if ($Spam == 0 ) { // Redirect visitor if form was on site, or display an message if form was in window switch ($FDMode) { case 0 : case 1 : case 2 : $loc = 'Location: ' . $FWebsiteAfter; header($loc); exit; case 3: echo 'We received your message, thank you for contacting us.'; } return 0; } } } // preparing font formating $ft = ' ContactForm
Class Registration

Your Name
Your Email Address
Phone Number
Select Class to register




Select Class Date





Select Class Time


Goal of learning


Eexperience and commend.
     

Home Program Philosophy Research Videos Video Shop Fitness World link Class Info Jingshan Tang

 

Contact: