-1

I am trying to make a post from postman to the server. Everything seems alright but when I attempt to make a post it returns an error as shown

<th align='left' bgcolor='#f57900' colspan="5">
                <span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: name in Upload-Download-PDF-File-Demo\upload.php on line
                <i>27</i>
            </th>

Here is the snippet on the php file

$response = array();
if($_SERVER['REQUEST_METHOD']=='POST'){

    //checking the required parameters from the request


        //connecting to the database
        //$con = mysqli_connect(DB_HOST,DB_USERNAME,DB_PASSWORD,DB_NAME) or die('Unable to Connect...');
        $con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect...');

        //getting name from the request
        $name = $_POST['name'];

Here is a picture on my attempt from postman

This is my first time experiencing this type of error. Please what could be wrong

Sleek
  • 135
  • 2
  • 2
  • 9
  • this is what is in line 27 $name = $_POST['name']; and nothing else – Sleek Jan 16 '18 at 20:58
  • @icecub please see the attached image – Sleek Jan 16 '18 at 21:00
  • Read the answers already given to you. You need to switch to `x-www-form-urlencoded` in Postman. Aside from that, I have no idea. I know nothing about Postman. The error basicly means that `$_POST['name']` doesn't exist. It has no value. – icecub Jan 16 '18 at 21:02
  • maybe the title of my question is duplicate but the error I am experiencing at the moment is not duplicate – Sleek Jan 16 '18 at 21:03
  • @icecub then how do I attach file – Sleek Jan 16 '18 at 21:04
  • The attached image shows a successful JSON response from the server, not the error you're referring to. Are you showing the correct image? – jhilgeman Jan 16 '18 at 22:00
  • please check to see the error image once again – Sleek Jan 16 '18 at 22:14

2 Answers2

0

Switch to x-www-form-urlencoded in Postman to mimic an HTML form

Josh
  • 4,009
  • 2
  • 31
  • 46
-1

It means you don't have a POSTed value called "name". Probably due to the wrong form encoding.

jhilgeman
  • 1,543
  • 10
  • 27