简体   繁体   中英

controller to controller in codeigniter

i have a php page where i have a link which calls a controller function page_view . within that controller function there are some codes which retrieve data using models and store in variable data then a view is loaded as $this->load->view('common/view_plan',$data);

in the view_plan page there is a form. when this form is submitted the data in the form is to be saved and then should get redirected to the same view_plan . so i wrote a controller function to save the data. but how can i redirect to the same page. can i call the controller function page_view from another controller

If you are submitting and showing the form in the same method of the same controller you could do something like this:

public function view_page() {
   if (!empty($_POST)) {
      // your form submission logic here
   }

   // your regular steps with fetching data from model and showing in the view
   $this->load->view('common/view_plan',$data);
}

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