Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP code for usage validation class
$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
You can’t perform that action at this time.