-1

I have a php file like this

<?php

header('Content-type: application/json');
echo $_POST['name'];
?>

then I do a post request using postman,

enter image description here

The actual error is Undefined index: name

Madeline Ries
  • 599
  • 1
  • 8
  • 18

2 Answers2

1

Just try like this: Select 'form-data' radio button under body near the 'x-www-form-urlencode' and try again.

Anand Pandey
  • 2,025
  • 3
  • 20
  • 39
-1

You have set the Content-type to json, so you should return json response. change the statement from $_POST['name'] to json_encode($_POST['name']);