Monday, April 20, 2015

set flash data in codeigniter

first go to your controller: e.g mycontroller.php and think this is a method your form will post into it:
------------------------------------------------
public function submitData(){
        $my_input = $this->input->post('form_input_name');

        /******insert these data to database************/
 $insertJournalDrData = array(
                "field_name" => $my_input
                 );
    $ledger_id=$this->Model->isnertData('tableName',$insertData);
      /********end of insertion in database***********/
        $this->session->set_flashdata('success_message','Data Saved Successfully!');
        redirect('mycontroller');
    }

secondly, your view will be like this:
--------------------------------------------------
<?php if ($this->session->flashdata('success_message') != ''):?>
      <div class="alert alert-success" role="alert">
             <?php echo $this->session->flashdata('success_message');?>
       </div>
<?php endif;?>

Note: here database is not important, you can do it without database.

No comments:

Post a Comment

Suomen kieli (Imperfekti)

In Finnish, the imperfekti is the past tense that describes actions that happened in the past, like the English simple past (e.g., "I ...