<?PHP/**************** Implementing data validation **********************8*//** * to detect Arabic numerals * * only allowed to enter Arabic numerals * * @access public * @param numeric parameters*/ functionCheckisnumeric ($numeric) { return!Preg_match("/^(\-?) (\d+) $/",Trim($numeric)) ?false:true; } /** * detect non-numeric characters * * Only allow input of non-numeric characters * * @access public * @param string parameter*/ functionCheckisstring ($string) { return!Preg_match("/^(\-?) (\d+) $/",Trim($string),$matches) ?false:true; } /** * Detect non-numeric and alphabetic combination characters (with mid-bar, down-stroke) * * Only allow input of alphanumeric characters (with middle bars, lower strokes) * * @access public * @param string parameter /c5>*/ functionCheckisstringandnumericplus ($string) { return!Preg_match("/^ ([_-a-za-z0-9]) +$/i",$string) ?FALSE:TRUE; } /** * Detect mobile phone number * * detect mobile phone number * * @access public * @param mobile phone number*/ functionCheckmobile ($mobile) { return(!Preg_match("/^ (13|15|18) [0-9]{9}$/",Trim($mobile))) ?false:true; } /** * Detect Phone number * * detect phone number * * @access public * @param phone phone number*/ functionCheckphone ($phone) { return!Preg_match("/^ ([0-9]| [-]) +$/",Trim($phone)) ?false:true; } /** * Check URL format * * Check URL format * * @access public * @param URL URL address*/ functionCheckurl ($url) { if(Preg_match('/^ (HTTP|HTTPS): \/\/[a-za-z0-9]+\. [a-za-z0-9]+[\/=\?%\ -&_~ ' @[\]\ ': +!] * ([^<>\]) *$/',$url)) { return true; } Else { return false; } } /** * Check email format * * Check email format * * @access public * @param Email*/ functionCheckemail ($email) { return( !Preg_match("/^ ([a-z0-9\+_\-]+) (\.[ a-z0-9\+_\-]+) *@ ([a-z0-9\-]+\.) +[a-z]{2,6}$/ix ",$email)) ?FALSE:TRUE; }?>
PHP Data validation