Here is my login method inside the controller, Here I am setting a flash message for the validation errors -
public function login(){
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[3]');
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[3]');
if($this->form_validation->run() == FALSE){
$data = array(
'errors' => validation_errors()
);
$this->session->set_flashdata($data);
redirect('home');
}
}
Here id the code to display those errors -
<?php if($this->session->flashdata('errors')): ?>
<?php echo $this->session->flashdata('errors');?>
<?php endif; ?>
I don't know what is wrong, Error message is not displaying.
I hope work this process
if($this->form_validation->run() == FALSE){
$this->session->set_flashdata('name','Your message');
redirect('home');
}
<?php if($this->session->flashdata('name')): ?>
<?php echo $this->session->flashdata('name');?>
<?php endif; ?>