Today, We want to share with you how to pass data from view to controller in codeigniter.In this post we will show you how to pass data from model to view in codeigniter, hear for how to pass data from controller to view in php we will give you demo and example for implement.In this post, we will learn about How To Pass Array From View To Controller? with an example.
Pass Data Between View and Controller in CodeIgniter
Step 1: View to Controller
Step 2: Controller
load->helper('url'); } public function index(){ // Check form submit or not if($this->input->post('submit') != NULL ){ // POST data $postData = $this->input->post(); // Read POST data echo "Name : ".$postData['member_name']."
"; echo "Membername : ".$postData['member_profile_name']."
"; echo "Email : ".$postData['member_email']."
"; } // load view $this->load->view('member_view'); } }
Controller to View
View Code
Name : ".$response['member_name']."
"; echo "Membername : ".$response['member_profile_name']."
"; echo "Email : ".$response['member_email']."
"; } ?>
Controller Code
load->helper('url'); } public function index(){ $data = array(); // Check form submit or not if($this->input->post('submit') != NULL ){ // POST data $postData = $this->input->post(); $data['response'] = $postData; } // load view $this->load->view('member_view',$data); } }
3. By URL
View Code
= "memberid : ".$memberid."
" ?> = "membername : ".$membername."
" ?>
S.no | Name | Membername | |
---|---|---|---|
1 | Virat Kohali | viratkohali | Edit |
2 | Bhavika Pethani | bhavikapethani | Edit |
3 | Jigar Shah | jigarshah | Edit |
Controller Code
load->helper('url'); } public function index($memberid = 0, $membername = ""){ // $memberid = $this->uri->segment(3); // $membername = $this->uri->segment(4); $data['memberid'] = $memberid; $data['membername'] = $membername; // load view $this->load->view('member_view',$data); } }
I hope you get an idea about how to pass value in url in codeigniter.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.