Home CodeIgniter display a redirect message
Reply: 0

CodeIgniter display a redirect message

user1969 Published in May 23, 2018, 4:39 pm

I am currently using XAMPP to serve up a CodeIgniter version 3.1.7 dynamic Web Application.

My goal is to be able to see if a certain user was created/registered without looking at the DB (making it visible even for a normal user).

In previous versions of the framework, such as 3.0.1, one could solve this issue, displaying redirect messages, by:

  • Using 'set_flashdata' & 'Redirect()' in a users.php file in Controller, as the following:

      $this->session->set_flashdata('user_registered', 'User has been registered');
  • Using the following in the View:

    <?php if($this->session->flashdata('user_registered')): ?>
    <?php echo ($this->session->flashdata('user_registered')); ?>
    <?php endif; ?>

But as mentioned above, I am currently using CodeIgniter version 3.1.7 and when registering the user, during the redirect, it seems that the CodeIgniter is resetting the data.

Note: A flash data should keep the "data" for the next request, and after that request is made, it should automatically remove that data.

In order to solve the issue with this current version and to display a redirect message, I have tried using the following code in the users.php (Controllers):

      $this->session->set_flashdata('user_registered', 'User has been registered');
      $data = array('main_view' => 'home_view');
      $this->load->view('layouts/main', $data);

But I am still not able to see the redirect message...

I've checked the error log and the console for errors and nothing was found.

How can i achieve my goal?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.342837 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO