Monday 24 February 2014

Filled Under:

How to display error messages in codeigniter

         in this post i have explain that how to display message in codeigniter using flashdata. if you assign your message as flashdata than no need to pass the data to the view. below given example,




Controller:
 
if (!$this->cart->contents())
{
    $this->data['msg'] = 'Your Email and Password is Empty!';
}

$this->load->view('templates/header', $this->data);
$this->load->view('bookings', $this->data);
$this->load->view('templates/footer');

View:
 
<div id="infomsg"><?php echo $msg;?></div>

Using flashdata

Controller:

if (!$this->cart->contents())
{
    $this->session->set_flashdata('msg', 'Your Email and Password is Empty!');
}

redirect('Your Controller Name');
 
View:

 <div id="infoMessage"><?php echo $this->session->flashdata('msg');?></div>

 







0 comments:

Post a Comment