简体   繁体   中英

Redirect to previously loaded page in codeigniter

I have a page to select district and school and when the page is submitted the employees of that school is listed below.And and from there is an edit page to edit employee details. In that page I have a back button which must redirect to previous page where district, school and employees have to be preloaded. I'm using codeigniter framework. I used the following code

$ref = $_SERVER['HTTP_REFERER']; echo anchor($ref,' ');

Bu the problem is the page is promting to select district and school .The preloaded values are not retaining in the page.Can you please tell how it could be done.

To restore the form fields . you can use set_vale()

Example :

<input type = "text" name = "district" value = "<?php echo (set_value("district") != ""):set_value("district"):" "; ?>" /> 

Add bewlos lines in all pages before checking login status/session:

$current_url = current_url();
$CI->session->set_userdata('current_url',$current_url);

and after login :

redirect user to above page like :

if($this->session->userdata('current_url') != '')
{
   header('Location: '.$this->session->userdata('current_url'));
   exit();
}
else
{
   header('Location: '.get_client_url().'home');
   exit();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM