1

I'm trying to use the inbuilt this->input->post('name') function when creating the Sign Up API in CodeIgniter, but this->input->post() returns an empty array.

I am using the same url on the browser and it works perfectly fine there but when I try to use it on Postman, it is returning null

I had tried:

print_r($_POST).

I had also used POST And GET Method but show nothing.

which also gives null

For testing purpose I created a function in which I used the form and post method to send data that worked fine on the browser but showed nothing on Postman.

**TESTING Function**
public function test()
{
    echo '<form method="POST"> <input name="name" ><input type="submit"> </form>';
    // print_r($_POST);
    die(var_dump($_POST));
}

On Postman

On Browser

1 Answer 1

0

CodeIgniter sometimes acts crazy while getting application/json post values. You can use

$_POST = file_get_contents('php://input');

You will get an array of post values received from Postman with Content-type: application/json header.

Sign up to request clarification or add additional context in comments.

1 Comment

I have also used $_POST = json_decode(file_get_contents("php://input"), true); this but it show nothing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.