Ok, So i am creating a simple callback function to check to see if the user has inserted a banned word. Here i what i have so far: (This is using codeigniter and tankauth)
$this->form_validation->set_rules('firstname', 'First Name', 'trim|alpha|xss_clean|min_length[2]|max_length[50]|callback_is_banned_word');
$this->form_validation->set_rules('lastname', 'Last Name', 'trim|alpha|xss_clean|min_length[2]|max_length[50]|callback_is_banned_word');
is_banned_word() function:
//Check if first or last name is a banned word
function is_banned_word($input) {
$banned_words = array("word1","word2",...."wordn"); //This is a really long array
foreach($banned_words as $words) {
if (stripos($input,$words) !== false) {
$this->form_validation->set_message('is_banned_word', 'There is a banned word your phrase.');
return FALSE;
}
else {
return TRUE;
}
}
return TRUE;
}
Any help?