Skip to content

Instantly share code, notes, and snippets.

@djonatanb
Created September 19, 2011 13:26
Show Gist options
  • Save djonatanb/1226486 to your computer and use it in GitHub Desktop.
Save djonatanb/1226486 to your computer and use it in GitHub Desktop.
Callback para funcionamento de plugin de validação de formulário
public function valida_acesso($value) {
if (!empty($value)) {
return $this->_model->valida_acesso($value);
}
}
public function valida_acesso($usuario) {
$dados = $this->Login_model->findAll(
array('where' => array('USUARIO_LOGIN' => $usuario, 'USUARIO_SENHA' => md5($_POST['password'])))
);
if (empty($dados)) {
$this->form_validation->set_message('valida_acesso', 'Usuário e/ou senha incorretos');
return FALSE;
} else {
return TRUE;
}
}
public function __construct() {
parent::__construct();
$this->load->model('Login_model');
public $validation = array(
array(
'field' => 'usuario',
'label' => 'Validação',
'rules' => 'callback_valida_acesso'
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment