Board index » delphi » how to send data to a server with the post method

how to send data to a server with the post method

Hi !

How is it possible to send data with method=POST to a PHP script for
example.

TIA.

 

Re:how to send data to a server with the post method


Use a HTTP component that supports post (like Indy) or use a TClientSocket
and send the following string/data.

// ----------------------------
POST /scripts/somescript.dll HTTP/1.0
Host: TheServer.com
Content-Length: 11

a=1&b=2&c=3
// ----------------------------
Note the cr/lf between the http header and the post data.

Paul

Quote
"Martin RODOT" <MRo...@mrit.kom> wrote in message

news:90luno$gc5@bornews.inprise.com...
Quote
> Hi !

> How is it possible to send data with method=POST to a PHP script for
> example.

> TIA.

Re:how to send data to a server with the post method


Thanks !
I have heard about Indy, but unable to find the home page.
If someone have it...

Paul Gertzen <pgert...@livetechnology.com> a crit dans le message :
90m5rm$...@bornews.inprise.com...

Quote
> Use a HTTP component that supports post (like Indy) or use a TClientSocket
> and send the following string/data.

> // ----------------------------
> POST /scripts/somescript.dll HTTP/1.0
> Host: TheServer.com
> Content-Length: 11

> a=1&b=2&c=3
> // ----------------------------
> Note the cr/lf between the http header and the post data.

> Paul

> "Martin RODOT" <MRo...@mrit.kom> wrote in message
> news:90luno$gc5@bornews.inprise.com...
> > Hi !

> > How is it possible to send data with method=POST to a PHP script for
> > example.

> > TIA.

Re:how to send data to a server with the post method


Quote
Martin RODOT wrote:
> I have heard about Indy, but unable to find the home page.

http://www.nevrona.com/Indy

--
Rune

Re:how to send data to a server with the post method


Hi !

I cannot find the exact data to send with Indy Thttpclient.

I  tried the following,
I tried also without the 3 and 4 first lines, since these informations are
already entered in the component properties.
------------------------------------------------
POST /Test/MyTest.php3 HTTP/1.0
Host: www.myhost.com
Content-Length: 11

p1=v1&p2=v2
----------------------------------------------------

The script never gets any value in parameters p1, p2.
It works with a form...

Thanks for help !

Martin RODOT <MRo...@mrit.kom> a crit dans le message :
90ojkd$o...@bornews.inprise.com...

Quote
> Thanks !
> I have heard about Indy, but unable to find the home page.
> If someone have it...

> Paul Gertzen <pgert...@livetechnology.com> a crit dans le message :
> 90m5rm$...@bornews.inprise.com...
> > Use a HTTP component that supports post (like Indy) or use a
TClientSocket
> > and send the following string/data.

> > // ----------------------------
> > POST /scripts/somescript.dll HTTP/1.0
> > Host: TheServer.com
> > Content-Length: 11

> > a=1&b=2&c=3
> > // ----------------------------
> > Note the cr/lf between the http header and the post data.

> > Paul

> > "Martin RODOT" <MRo...@mrit.kom> wrote in message
> > news:90luno$gc5@bornews.inprise.com...
> > > Hi !

> > > How is it possible to send data with method=POST to a PHP script for
> > > example.

> > > TIA.

Re:how to send data to a server with the post method


Try

SL.Add('p1=v1');
SL.Add('p2=v2');

IdHttp1.Post('http://www.myhost.com/Test/MyTest.php3 ', SL, res);

SL is TStringList and res is result stream.

Doychin

Quote
"Martin RODOT" <MRo...@mrit.kom> wrote in message

news:91795g$rl45@bornews.inprise.com...
Quote
> Hi !

> I cannot find the exact data to send with Indy Thttpclient.

> I  tried the following,
> I tried also without the 3 and 4 first lines, since these informations are
> already entered in the component properties.
> ------------------------------------------------
> POST /Test/MyTest.php3 HTTP/1.0
> Host: www.myhost.com
> Content-Length: 11

> p1=v1&p2=v2
> ----------------------------------------------------

> The script never gets any value in parameters p1, p2.
> It works with a form...

> Thanks for help !

> Martin RODOT <MRo...@mrit.kom> a crit dans le message :
> 90ojkd$o...@bornews.inprise.com...
> > Thanks !
> > I have heard about Indy, but unable to find the home page.
> > If someone have it...

> > Paul Gertzen <pgert...@livetechnology.com> a crit dans le message :
> > 90m5rm$...@bornews.inprise.com...
> > > Use a HTTP component that supports post (like Indy) or use a
> TClientSocket
> > > and send the following string/data.

> > > // ----------------------------
> > > POST /scripts/somescript.dll HTTP/1.0
> > > Host: TheServer.com
> > > Content-Length: 11

> > > a=1&b=2&c=3
> > > // ----------------------------
> > > Note the cr/lf between the http header and the post data.

> > > Paul

> > > "Martin RODOT" <MRo...@mrit.kom> wrote in message
> > > news:90luno$gc5@bornews.inprise.com...
> > > > Hi !

> > > > How is it possible to send data with method=POST to a PHP script for
> > > > example.

> > > > TIA.

Re:how to send data to a server with the post method


Hi !

I have tried it... and result is the same.
The source :
Requete := TStringList.Create ;
Requete.Add ( 'A=001');
Requete.Add ( 'B=123456');
Reponse := TStringStream.Create ('') ;
http.post ( 'http://www.mrit.com/Essais/Demande.php3', Requete, Reponse );
showmessage ( Reponse.DataString );

I get a response, with every constant string printed by the script,  all
parameters are blank.

This is the script :
<html>
<head>
<title>Demande</title>
</head>
<body>
<?php
print ( "paramtres : <BR>" );
print ( "A = $A <BR>" );
print ( "B = $B <BR>" );
?>
</body>
</html>

A form at http://www.mrit.com/Essais/TestDemande.htm returns the expected
result...

Any idea ?   Any parameter that I could have forget ?

Regards.

Doychin Bondzhev <doic...@5group.com> a crit dans le message :
3a37cd56_2@dnews...

Quote
> Try

> SL.Add('p1=v1');
> SL.Add('p2=v2');

> IdHttp1.Post('http://www.myhost.com/Test/MyTest.php3 ', SL, res);

> SL is TStringList and res is result stream.

> Doychin

> "Martin RODOT" <MRo...@mrit.kom> wrote in message
> news:91795g$rl45@bornews.inprise.com...
> > Hi !

> > I cannot find the exact data to send with Indy Thttpclient.

> > I  tried the following,
> > I tried also without the 3 and 4 first lines, since these informations
are
> > already entered in the component properties.
> > ------------------------------------------------
> > POST /Test/MyTest.php3 HTTP/1.0
> > Host: www.myhost.com
> > Content-Length: 11

> > p1=v1&p2=v2
> > ----------------------------------------------------

> > The script never gets any value in parameters p1, p2.
> > It works with a form...

> > Thanks for help !

> > Martin RODOT <MRo...@mrit.kom> a crit dans le message :
> > 90ojkd$o...@bornews.inprise.com...
> > > Thanks !
> > > I have heard about Indy, but unable to find the home page.
> > > If someone have it...

> > > Paul Gertzen <pgert...@livetechnology.com> a crit dans le message :
> > > 90m5rm$...@bornews.inprise.com...
> > > > Use a HTTP component that supports post (like Indy) or use a
> > TClientSocket
> > > > and send the following string/data.

> > > > // ----------------------------
> > > > POST /scripts/somescript.dll HTTP/1.0
> > > > Host: TheServer.com
> > > > Content-Length: 11

> > > > a=1&b=2&c=3
> > > > // ----------------------------
> > > > Note the cr/lf between the http header and the post data.

> > > > Paul

> > > > "Martin RODOT" <MRo...@mrit.kom> wrote in message
> > > > news:90luno$gc5@bornews.inprise.com...
> > > > > Hi !

> > > > > How is it possible to send data with method=POST to a PHP script
for
> > > > > example.

> > > > > TIA.

Re:how to send data to a server with the post method


MRo...@mrit.kom (Martin RODOT) wrote in <91a4ir$1...@bornews.inprise.com>:

Quote
>Hi !

>I have tried it... and result is the same.
>The source :
>Requete := TStringList.Create ;
>Requete.Add ( 'A=001');
>Requete.Add ( 'B=123456');
>Reponse := TStringStream.Create ('') ;
>http.post ( 'http://www.mrit.com/Essais/Demande.php3', Requete, Reponse );
>showmessage ( Reponse.DataString );

>I get a response, with every constant string printed by the script,  all
>parameters are blank.

Can you send me a small project so Ican trace this? Witht the correct URL?

--
Hadi Hariri
http://delphi.urusoft.com

Other Threads