Location: PHPKode > scripts > Rapid Form Builder > rapid-form-builder/check.php
<?php
session_start();
/* ************************************************************
 ***  created by:  Christopher Knott, hide@address.com  http://digitallight.ca
 ***  shout out to http://ajax.phpmagazine.net/ajax_tutorials/ Hatem for his tutorial that got me started.
 ***  there are few comments in the code, but I did create a readme.txt file for explanations

 ***  this intro defines the first 3 letters of the field standards
 ***  so that we can pull out the data type for validation rules.
 ***
 ***  dat = data. contains numbers only
 ***  alp = alpha.  contains only letters
 ***  aln = alphanumeric.  numbers and letters only
 ***  phn = phone number, 10 numbers only
 ***  txt = no real restrictions
 ***  pwd = password
 ***  eml = email
 ***  sel = select box (drop down)
 ***  chk = checkbox
 ***  rad = radiobox

 Version 0.2 will iniclude the following
 ***  pos = postal code
 ***  zip = zip code
 ***  enc = encrypted variables, used for passing keys to pages
 ***  hid = hidden variables
 ***  additionally, 0.2 will include field focus on start and fail of a field entry 
 ***************************************************************
 *
 * displaying the error message:
 * the idea is that the more wrong = the higher the number.
 * 0 = pass (green)
 * 1 = conditional pass (black)
 * 2 = fail (red)
 */


$sid = $_SESSION['sid'] ;
include 'checkClasses.php' ; 
// databaseConnect ($connect) ; 

// get the fieldname and type
$ajaxField = $_REQUEST['field'] ;
$fieldType = substr($ajaxField, 0, 3);
$fieldMandatory = substr($ajaxField, 3, 1);

// get and sanitize the field data
$fieldData = $_REQUEST['value'] ;
// echo "fieldData: $fieldData <br> " ; 
$cleanData = new processFields ($fieldData) ; 
$cleanData = $cleanData->cleanField($fieldData) ;

// determine what type of validation it needs based on the above codes in the fieldname
$getMessages = new processFields () ; 

	$fullMessage = $getMessages->processTextField($ajaxField, $cleanData, $sid) ;
		
	if ($fieldType == "sel") {
		$fullMessage = $getMessages->processSelect($fieldName, $cleanData, $sid) ;
	}	
	
	if ($fieldType == "chk") {
		$fullMessage = $getMessages->processCheckBox($fieldName, $cleanData, $sid) ;
	}	
	
		$class = $getMessages->determineClass($fullMessage, $fieldMandatory) ;
		$msg =  substr($fullMessage, 1) ;
		
		echo "<?xml version='1.0' encoding='UTF-8'?>
		<span class=\"$class\">$msg</span>";


?>
Return current item: Rapid Form Builder