title: How to use libcurl in c++ to send a POST request and receive it?
body: <p>I am using the c++ libcurl to send a POST request to a webpage, but i am struggling test it. The code is use is:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;curl/curl.h&gt;
  #include &lt;string&gt;
  using namespace std;
  int main(void)
  {
      CURL *curl = curl_easy_init();
      if(curl) {
          const char *data = "submit = 1";
  
          curl_easy_setopt(curl, CURLOPT_URL, "http://10.5.10.200/website/WebFrontend/backend/posttest.php");
  
          /* size of the POST data */
          curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 10L);
  
          /* pass in a pointer to the data - libcurl will not copy */
          curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  
          curl_easy_perform(curl);
      }
  
  
      /* Perform the request, res will get the return code */ 
  
  
  
  
      /* always cleanup */ 
  
  
  
      return 0;
  }
  </code></pre>
  
  <p>This is the sample code from: <a href="https://curl.haxx.se/libcurl/c/CURLOPT_POSTFIELDS.html" rel="noreferrer">https://curl.haxx.se/libcurl/c/CURLOPT_POSTFIELDS.html</a></p>
  
  <p>The outcome really confuses me. From the terminal I can see there is POST request been sent but from the web page i cannot retrieve any data. The web page is very simple php code that prints out the $_POST.
  <a href="https://i.stack.imgur.com/Hs2kD.jpg" rel="noreferrer">terminal screenshot</a> and
  <a href="https://i.stack.imgur.com/3yFnt.png" rel="noreferrer">webpage screenshot</a></p>
  
  <p>Could anyone help me with this?
  Why i cannot get the POST request from the web page, and how can i fix this?
  Anyone can give me a better way to test the code?
  Thank you guys so much!</p>