[eluser]Harold Villacorte[/eluser]
This would be the normal way of doing it:
Code:
function comment($id){
$this->load->library('form_validation');
$this->form_validation->set_rules('name','Name','trim|required');
$this->form_validation->set_rules('email','Email','trim|required|valid_email');
$this->form_validation->set_rules('comment','Comment','required');
if($this->form_validation->run() == FALSE){
$this->load->view('the_same_view_file');
}
Then somewhere in the view file put something like this:
Code:
<?php if (validation_errors ()) : ?>
<div>
<?php echo validation_errors (); ?>
</div>
<?php endif; ?>
Else redirect:
Code:
else {
$this->session->set_flashdata('type_of_message', 'Your success message here.');
redirect (base_url() . 'whatever_url/' );
}
Then to echo the flashdata in the next view file:
Code:
<?php if ($this->session->flashdata('type_of_message')) : ?>
<div>
<?php echo $this->session->flashdata('type_of_message'); ?>
</div>
<?php endif; ?>
Or something to that effect.