Hi
this is the Post Function from the example "OverByteHttpTst1"
the only code I have changes is marked below
I have done a print_r($_POST) and verified my _Post array is indeed empty..
procedure THttpTestForm.PostOrPut(Request: THttpRequest);
var
DataOut : TMemoryStream;
DataIn : TFileStream;
Buf : String;
I : Integer;
begin OverbyteICSHttpTst1
DisplayMemo.Clear;
DocumentMemo.Clear;
SetButtonState(FALSE);
try
DataOut := TMemoryStream.Create;
// Buf := DataEdit.Text; // commented out this
// Below is the Only Line I changed in the whole program
Buf := '"FirstName=Gary&Submit=Submit"'; //this is the only mod
// Have Also tried the below but it does not work either
//Buf := 'type="text" id="FirstName" FirstName="Gary" type="submit"
name="submit"';
if Length(Buf) > 0 then { Check if some data to post }
DataOut.Write(Buf[1], Length(Buf));
DataOut.Seek(0, soBeginning);
HttpCli1.SendStream := DataOut;
HttpCli1.Proxy := ProxyHostEdit.Text;
HttpCli1.ProxyPort := ProxyPortEdit.Text;
HttpCli1.Connection := 'Keep-Alive';
HttpCli1.RcvdStream := nil;
HttpCli1.ContentTypePost := PostContentTypeEdit.Text;
HttpCli1.URL := URLEdit.Text;
HttpCli1.RequestVer := '1.' +
IntToStr(HttpVersionComboBox.ItemIndex);
if HttpCli1.Proxy <> '' then
Display('Using proxy ''' + HttpCli1.Proxy + ':' +
HttpCli1.ProxyPort + '''')
else
Display('Not using proxy');
try
if Request = httpPOST then
HttpCli1.Post
else
HttpCli1.Put;
except
DataOut.Free;
Display('POST Failed !');
Display('StatusCode = ' + IntToStr(HttpCli1.StatusCode));
Display('ReasonPhrase = ' + HttpCli1.ReasonPhrase);
Exit;
end;
DataOut.Free;
Display('StatusCode = ' + IntToStr(HttpCli1.StatusCode) +
' (' + HttpCli1.ReasonPhrase + ')');
if DisplayHeaderCheckBox.Checked then
for I := 0 to HttpCli1.RcvdHeader.Count - 1 do
Display('hdr>' + HttpCli1.RcvdHeader.Strings[I]);
if HttpCli1.ContentLength = 0 then
DocumentMemo.Lines.Add('No document received.')
else begin
DataIn := TFileStream.Create(HttpCli1.DocName, fmOpenRead);
try
if Copy(HttpCli1.ContentType, 1, 5) = 'text/' then
DocumentMemo.Lines.LoadFromStream(DataIn)
else begin
DocumentMemo.Lines.Add('Content type is ' +
HttpCli1.ContentType);
DocumentMemo.Lines.Add('Document stored in ''' +
DocFileName +
''' Size=' + IntToStr(DataIn.Size));
end;
finally
DataIn.Free;
end;
end;
finally
SetButtonState(TRUE);
end;
end;
> Date: Wed, 24 Mar 2010 14:40:07 -0400
> From: [email protected]
> To: [email protected]
> Subject: Re: [twsocket] POST and PHP
>
> Gary Howard wrote:
> > Hi
> >
> >
> >
> > It seems PHP does not like the way the data is "POST"
> >
> > there appears to be nothing in the _POST array...hence nothing to return
> >
> >
> >
> > shouldn't you simply be able to OutString := 'IDString=ABCD"
> >
> > then load the DataOutStream with OutString?
>
> Please post your Delphi code that sends the request to the PHP script.
> The same I said before is true for the request: the request must be
> composed of an HTTP header and the payload in order to be handled
> properly by the script.
>
> Take a look at the demo to see how the full request is made. The
> payload (Request Body) you quoted seems correct:
> "IDString=ABCD&Submit=Submit"
>
> but it depends on the complete data sent to the script in order to work
> properly. The THttpCli component should encapsulate the HTTP protocol
> correctly, sending the correct HTTP method, headers, and payload.
>
> dZ.
>
> --
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
_________________________________________________________________
Hotmail is redefining busy with tools for the New Busy. Get more from your
inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID27925::T:WLMTAGL:ON:WL:en-US:WM_HMP:032010_2
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be