CodeIgniter Forums
flash data display empty message - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: flash data display empty message (/showthread.php?tid=71130)



flash data display empty message - kvanaraj - 07-10-2018

My flash data showing null message in the display screen and also showing footer of the page

View file
*******
 <div class="col-md-12">
                <?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>
            </div>


Controller file
***********

$query = "insert into <some values in  table>"; 
             

            $result= $this->db->query($query);
          
            if($result == true)
                {
                    $this->session->set_flashdata('success', 'New student created successfully');
                }
                else
                {
                    $this->session->set_flashdata('error', 'student creation failed');
                }
                
                redirect('<view_name>');


RE: flash data display empty message - Pertti - 07-10-2018

Is this normal form submission or AJAX call? And you have sessions properly set up?

When it comes to flashdata going missing, first, check that there are no unintended redirects.

[Image: YC9dY.png]

Chrome DevTools has option to preserve log of network requests.

Go to Network tab, make sure Preserve log is checked, do submit the form and check that only one page load happens.