CodeIgniter Forums
flash data showing wrongly - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: flash data showing wrongly (/thread-71103.html)



flash data showing wrongly - kvanaraj - 07-06-2018

in my view
*********
 <div class="col-md-4">
                <?php
                    $this->load->helper('form');
                    $error = $this->session->flashdata('error');
                    if($error)
                    {
                ?>
                <div class="alert alert-danger alert-dismissable">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <?php echo $this->session->flashdata('error'); ?>                    
                </div>
                <?php } ?>
                <?php  
                    $success = $this->session->flashdata('success');
                    if($success)
                    {
                ?>
                <div class="alert alert-success alert-dismissable">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <?php echo $this->session->flashdata('success'); ?>
                </div>
                <?php } ?>
                
                <div class="row">
                    <div class="col-md-12">
                        <?php echo validation_errors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>'); ?>
                    </div>
                </div>


in controller
**********
$result= $this->User_model->studreginsert($insert);
         if($result == true)
                {
                    $this->session->set_flashdata('success', 'New student created successfully');
                }
                else
                {
                    $this->session->set_flashdata('error', 'student creation failed');
                }
                
                redirect('studreg');

values are inserted. but showing    $this->session->set_flashdata('error', 'student creation failed'); only . how to solve it?


RE: flash data showing wrongly - dave friend - 07-06-2018

Please show the code for User_model->studreginsert. It appears it is not returning true. Hard to know why that might be without seeing the code.


RE: flash data showing wrongly - kvanaraj - 07-06-2018

public function studreginsert($insert )
{

$this->db->insert_batch('pre_marks', $insert);
}


RE: flash data showing wrongly - jreklund - 07-07-2018

Change:
Code:
$this->db->insert_batch('pre_marks', $insert);
Into:
Code:
return $this->db->insert_batch('pre_marks', $insert);