title: How to send a HTTP Post Request in Delphi 2010 using WinInet
body: <p>I want to send a HTTP Post Request in Delphi 2010 using WinInet, but my script doesn't work ;/</p>
  
  <p>It's my Delphi script:</p>
  
  <pre><code>uses WinInet;
  procedure TForm1.Button1Click(Sender: TObject);
  var
    hNet,hURL,hRequest: HINTERNET;
  begin
    hNet := InternetOpen(PChar('User Agent'),INTERNET_OPEN_TYPE_PRECONFIG or INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
    if Assigned(hNet) then
    begin
    try
      hURL := InternetConnect(hNet,PChar('http://localhost/delphitest.php'),INTERNET_DEFAULT_HTTP_PORT,nil,nil,INTERNET_SERVICE_HTTP,0,DWORD(0));
      if(hURL&lt;&gt;nil) then
        hRequest := HttpOpenRequest(hURL, 'POST', PChar('test=test'),'HTTP/1.0',PChar(''), nil, INTERNET_FLAG_RELOAD or INTERNET_FLAG_PRAGMA_NOCACHE,0);
      if(hRequest&lt;&gt;nil) then
        HttpSendRequest(hRequest, nil, 0, nil, 0);
      InternetCloseHandle(hNet);
    except
        ShowMessage('error');
      end
    end;
  end;
  </code></pre>
  
  <p>and my PHP script:</p>
  
  <pre><code>$data = $_POST['test'];
  $file = "test.txt";
  $fp = fopen($file, "a");
  flock($fp, 2);
  fwrite($fp, $data);
  flock($fp, 3);
  fclose($fp);
  </code></pre>