[eluser]ibnclaudius[/eluser]
I'm not getting
Code:
$this->form_validation->set_message('register', 'User registered with success.');
on my form, but the other erros messages are OK
Code:
public function register() {
if ($this->input->post('action') == 'register_user') {
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|callback_exists_user');
$this->form_validation->set_rules('name', 'Nome', 'trim|required');
$this->form_validation->set_rules('password', 'Senha', 'trim|required');
$this->form_validation->set_rules('confirm_password', 'Confirmar Senha', 'trim|required|matches[password] ');
if ($this->form_validation->run() == FALSE) {
//fail message
} else {
$data = array('name' => $this->security->sanitize_filename($this->input->post('name')),
'email' => $this->security->sanitize_filename($this->input->post('email')),
'password' => $this->encrypt->sha1($this->security->sanitize_filename($this->input->post('password'))),
'time' => date('Y-m-d H:i:s')
);
$query = $this->Model->create($this->users_table, $data);
if ($query) {
$this->form_validation->set_message('register', 'User registered with success.');
} else {
//failmessage
}
}
}
$data['page_title'] = "Registrar";
$data['query'] = $this->Model->get_all_users();
$this->load->view('header', $data);
$this->load->view('register');
$this->load->view('footer', $data);
}
Code:
public function create($table, $data) {
$query = $this->db->insert($table, $data);
if ($query) {
return TRUE;
} else {
return FALSE;
}
}
Code:
<?=form_open('user/register')?>
<?=form_hidden(array('action' => 'register_user'))?>
<p>Nome:</p>
<p><?=form_input(array('name' => 'name', 'id' => 'name'))?></p>
<p>Email:</p>
<p><?=form_input(array('name' => 'email', 'id' => 'email'))?></p>
<p>Senha:</p>
<p><?=form_password(array('name' => 'password', 'id' => 'password'))?></p>
<p>Confirmar Senha:</p>
<p><?=form_password(array('name' => 'confirm_password', 'id' => 'confirm_password'))?></p>
<p><?=validation_errors()?></p>
<p><?=form_submit('submit', 'Registrar')?></p>
<?=form_close()?>