Created
July 31, 2016 14:11
-
-
Save rakeshkumar125/c4c3d3610465ac801c2656af8f393edb to your computer and use it in GitHub Desktop.
PHP code for usage validation class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$config = array(); | |
$config['array_to_validate'] = $_POST or array_need_to_validate; | |
$config['email'] = "email,forgot_email"; | |
$config['required'] = "date_birth,phone,mobile"; | |
$config['numeric'] = "mobile"; | |
$config['positive_numeric'] = "positive_number"; | |
$config['positive_integer'] = "positive_integer"; | |
$config['url'] = "url"; | |
$config['alpha'] = "name"; | |
$config['alphanumeric'] = "user_password"; | |
Now its some thing different because this validation the database. field_name means provide the textbox name or element that need to validation. | |
$config['unique_from_table'] = array( | |
array( | |
'field_name' =>'', | |
'table_name' =>'user', | |
'table_field'=>'username' | |
), | |
array( | |
'field_name' =>'', | |
'table_name' =>'users', | |
'table_field'=>'username' | |
), | |
); | |
$config['compare'] = array( | |
array( | |
'field_name' =>'username', | |
'compare_field_name' =>'firstname', | |
), | |
array( | |
'field_name' =>'lastname', | |
'compare_field_name' =>'firstname' | |
) | |
); | |
$config['min_character_limit'] = array( | |
array( | |
'field_name' =>'username', | |
'no_of_character' =>'20', | |
), | |
array( | |
'field_name' =>'lastname', | |
'no_of_character' =>'30' | |
) | |
); | |
$config['max_character_limit'] = array( | |
array( | |
'field_name' =>'username', | |
'no_of_character' =>'20', | |
), | |
array( | |
'field_name' =>'lastname', | |
'no_of_character' =>'30' | |
) | |
); | |
$error = $my_validator->process_validation(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment