Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Delphi para la web (https://www.clubdelphi.com/foros/forumdisplay.php?f=51)
-   -   Ayuda con función en Delphi (https://www.clubdelphi.com/foros/showthread.php?t=84218)

JuanOrtega 22-09-2013 19:09:19

Ayuda con función en Delphi
 
Tengo el siguiente código en Delphi :

Código Delphi [-]
function Check(const UserAgent: string; const Server: string; const Resource: string; const Data: AnsiString): string;
    var
      hInet: HINTERNET;
      hHTTP: HINTERNET;
      hReq: HINTERNET;
      Buffer: array[0..1023] of AnsiChar;
      i, BufferLen: Cardinal;
    const
      accept: packed array[0..1] of LPWSTR = (PChar('*/*'), nil);
      header: string = 'Content-Type: application/x-www-form-urlencoded';
    begin
      Result := '';
     
      hInet := InternetOpen(PChar(UserAgent), INTERNET_OPEN_TYPE_PRECONFIG,
        nil, nil, 0);
      try
        hHTTP := InternetConnect(hInet, PChar(Server), INTERNET_DEFAULT_HTTP_PORT, nil, nil, INTERNET_SERVICE_HTTP, 0, 1);
        try
          hReq := HttpOpenRequest(hHTTP, PChar('POST'), PChar(Resource), nil, nil, @accept, 0, 1);
          try
            if not HttpSendRequest(hReq, PChar(header), Length(header), PChar(Data), Length(Data)) then
              raise Exception.Create('HttpOpenRequest failed. ' + SysErrorMessage(GetLastError));
            repeat
              InternetReadFile(hReq, @Buffer, SizeOf(Buffer), BufferLen);
              if BufferLen = SizeOf(Buffer) then
                Result := Result + AnsiString(Buffer)
              else if BufferLen > 0 then
                for i := 0 to BufferLen - 1 do
                  Result := Result + Buffer[i];
            until BufferLen = 0;
          finally
            InternetCloseHandle(hReq);
          end;
        finally
          InternetCloseHandle(hHTTP);
        end;
      finally
        InternetCloseHandle(hInet);
      end;
    end;
     
  
Memo1.Lines.Add(Check('Agente','localhost','pos.php','probar=test+submit=Now'));

Mi duda está en el tercer argumento en el cual tengo que poner los datos para POST:

'probar=test+submit=Now'

Estos datos no funcionan ya que cuando capturo la respuesta en el memo se muestra que el metodo post funciono mal

El código del archivo pos.php es


Código PHP:

<form action='' method=POST>
<input type=text name=probar value=test>
<input type=submit name=control value=Now>
</form>
<br><br>

<?php 
if (isset($_POST['control'])) {
echo 
$_POST['probar']."<br>";
}
?>

La pregunta es: ¿cómo ordeno el tercer argumento para que el formulario funcione bien?

¿ Alguien me puede ayudar ?


La franja horaria es GMT +2. Ahora son las 18:51:10.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi