user7523193
user7523193

Reputation:

How to post data using codeigniter?

How to map post data to variables

handy.php

     if($this->input->method() === 'post') {
        $obj = json_decode($this->input->raw_input_stream);
        print_r($this->input->raw_input_stream);
        print_r($obj);
        $name = $obj->name;         
        $mobile  = $obj->mobile;
        $state = $obj->state;
         }

My postman response isPostman response

Upvotes: 0

Views: 284

Answers (1)

BSB
BSB

Reputation: 2468

In codeigniter If you are sending xyz = 'some_value' using post you can set that POST value in variable as

$xyz = $this->input->post('xyz');

Your code should look like:

if($this->input->post()) {
        $name = $this->input->post('name');         
        $mobile  = $this->input->post('mobile');
        $state = $this->input->post('state');
}

Assuming that you have sent some data for name, mobile and state. You can clear notices at your own.

Upvotes: 1

Related Questions