How to call certain div class when certain condition is done? |
[eluser]Michal1[/eluser]
Hello guys, I have pretty basic and stupid question. How to show certain div class when some condition is done. Let say in my view I have Code: <div class="msg msg-ok"> and in my controller i have function which handles adding articles. Code: public function add_thread() and after this is done I want to display that msg msg-ok from my view. How to do that please?
[eluser]Silviu[/eluser]
I've noticed that you are using a redirect (presumably, after the form was successfully submitted). You can use a flashdata session variable as a hook for that message: Code: public function add_thread() Code: <?if($this->session->flashdata('success')):?>
[eluser]dhiya[/eluser]
Try this solution: in your view: <?php if(isset($message)){ ?> <div class="msg msg-ok"> <p><strong>Your file was uploaded succesifully!</strong></p> <a href="#" class="close">close</a> </div> <?php } ?> in your controller: public function add_thread() { $data = array( 'name' =>$this->input->post('name'), 'text'=>$this->input->post('text') ); if($this->site_model->insert_thread($data)) { $data['message'] = 'your message here'; } $this->load->view('your_view.php',$data); redirect ('site'); }
|
Welcome Guest, Not a member yet? Register Sign In |