Welcome Guest, Not a member yet? Register   Sign In
set_message
#1

[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 Confused

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>&lt;?=form_input(array('name' => 'name', 'id' => 'name'))?&gt;</p>
<p>Email:</p>
<p>&lt;?=form_input(array('name' => 'email', 'id' => 'email'))?&gt;</p>
<p>Senha:</p>
<p>&lt;?=form_password(array('name' => 'password', 'id' => 'password'))?&gt;</p>
<p>Confirmar Senha:</p>
<p>&lt;?=form_password(array('name' => 'confirm_password', 'id' => 'confirm_password'))?&gt;</p>
<p>&lt;?=validation_errors()?&gt;</p>
<p>&lt;?=form_submit('submit', 'Registrar')?&gt;</p>
&lt;?=form_close()?&gt;


Messages In This Thread
set_message - by El Forum - 12-23-2011, 04:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB