sepuluh10
sepuluh10

Reputation: 1

How to passing data array from view to controller with codeigniter

I had a problem when trying to retrieve data from the array ( from view to controller ) , I've tried to use the session in view . but could not as well .

contrroller:

public function returnurl()
    {
        $dataview =  $this->load->view('user/return_url');
        // $this->load->view($this->template,$dataview);

        $status = $dataview['PAYMENT_STATUS'];

        if ($status == 'S'){
            redirect(site_url('registration/previewData'));
        } else {
            redirect(site_url());
        }
    }

view:

<?php
 var_dump($_POST);exit;

 foreach ($_POST as $name => $value) {
    echo $name . ' : ' . $value . '<br />';

}

$this->session->set_userdata($_POST);
  ?> 
</body>
</html>

Output array from view:

array(2) { ["PAYMENT_STATUS"]=> string(1) "S" ["MERCHANTID"]=> string(9) "testingid"}

I would like if payment_status = 'S' . he will redirect another page (as I have defined in the controller).

Has anyone already encountered this problem ? Please help , thanks before .

Upvotes: -1

Views: 125

Answers (1)

Shomz
Shomz

Reputation: 37701

That's not how MVC works. Please read more about what each of them stands for. The data is passed from a controller to the view for presentation.

In order to pass some data to a controller, you should make another server request (like submitting a form or making an AJAX call) and then read the data.

Upvotes: 1

Related Questions