🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
5 messages
5 total messages Started by Denville Longhurst Tue, 31 Jan 2006 17:22
Indy version, Post method
#795
Author: Denville Longhurst
Date: Tue, 31 Jan 2006 17:22
19 lines
1656 bytes
Please, I am going round in circles...

I want to mimic a simple form (three or four fields) and post the data to a 
web site, then receive the (simple text) reply (for testing I have set up a 
PHP script that just bounces back a summary of the data).

I have BCB6 SP2.  I guess I need to use TldHTTP.  In my help, it doesn't 
even document a Post (or a Get) method, but I know they are there.

Please, genltefolk,:

-How do I find what version of Indy I have in my BCB setup.  If I need to 
upgrade, how do I do that (the Indy site sends me round in circles) ?
-How to I put the post data (eg Name=Denville, Address=Leeds) into the Post 
command and get the return result to a String or String List ?

Please help me regain my sanity.

Denville. 
Re: Indy version, Post method
#797
Author: Remy Lebeau (TeamB)
Date: Tue, 31 Jan 2006 18:07
42 lines
2119 bytes
"Denville Longhurst" <Denville@metco.co.uk> wrote in message
news:43df9c82@newsgroups.borland.com...

> I want to mimic a simple form (three or four fields) and post
> the data to a web site

How you do that exactly depends on how the PHP script is set up.  Please
show the HTML for the form so we can see what kind of values the server is
expecting to be sent.

> I have BCB6 SP2.  I guess I need to use TldHTTP.

Yes.

> In my help, it doesn't even document a Post (or a Get) method

TIdHTTP is a third-party component, not a Borland one.  You can download the
documentation from http://www.indyproject.org.

> but I know they are there.

Yes, there are - several different flavors, in fact.

> How do I find what version of Indy I have in my BCB setup.

Right-click on any Indy component in the Form Designer.

> If I need to upgrade, how do I do that (the Indy site sends me round in
circles) ?

Did you read the Indy Knowledge Base yet?  There are install instructions in
it.

> How to I put the post data (eg Name=Denville, Address=Leeds)
> into the Post command and get the return result to a String or String List
?

Again, it depends on what the HTML looks like.


Gambit
Re: Indy version, Post method
#800
Author: Denville Longhurst
Date: Tue, 31 Jan 2006 23:33
97 lines
4149 bytes
OK, here is a simple, working form that illustrates what I want to achieve
from a BCB application using Indy (TIdHTTP v 8.0.25).  The first few hidden
inputs are necessary to set up the 3rd party PHP script which e-mails me the
contents and bounces back the acknowledgment.  The MyName and MyTown inputs
represent real data.

Thanks for your time.  (Sorry if you got this twice, I clicked Reply instead 
of Reply Group.)

//---------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Simple Form </title>
<style type="text/css">
<!--
.style1 {font-family: "Courier New", Courier, mono}
-->
</style>

</head>
<form name="FplForm" action="http://cgi.uk2.net/cgi-bin/uk2-formmail.pl"
method="POST">

<input type="hidden" name="recipient" value="fpl@metco.co.uk">
<input type="hidden" name="env_report"
value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT">
<input type="hidden" name="print_config" value="email,realname,subject">
<input type="hidden" name="sort" value="order:message">
<input type="hidden" name="print_blank_fields" value="1">
<input type="hidden" name="redirect"
value="http://www.metco.co.uk/MyTemp/FplWeback1.htm">
<input type="hidden" name="email" value="a.pilot@metco.co.uk">

<p>Name<input name="MyName" type="text" id="MyName" value="Denville"></p>
<p>Town<input name="MyTown" type="text" id="MyTown" value="Leeds,
England"></p>

<p><input type="submit" name="Submit" value="Submit"></p>

</form>
</body>
</html>
//---------------------------------------------------------------------------


"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:43dfa6dd$5@newsgroups.borland.com...
>
> "Denville Longhurst" <Denville@metco.co.uk> wrote in message
> news:43df9c82@newsgroups.borland.com...
>
>> I want to mimic a simple form (three or four fields) and post
>> the data to a web site
>
> How you do that exactly depends on how the PHP script is set up.  Please
> show the HTML for the form so we can see what kind of values the server is
> expecting to be sent.
>
>> I have BCB6 SP2.  I guess I need to use TldHTTP.
>
> Yes.
>
>> In my help, it doesn't even document a Post (or a Get) method
>
> TIdHTTP is a third-party component, not a Borland one.  You can download 
> the
> documentation from http://www.indyproject.org.
>
>> but I know they are there.
>
> Yes, there are - several different flavors, in fact.
>
>> How do I find what version of Indy I have in my BCB setup.
>
> Right-click on any Indy component in the Form Designer.
>
>> If I need to upgrade, how do I do that (the Indy site sends me round in
> circles) ?
>
> Did you read the Indy Knowledge Base yet?  There are install instructions 
> in
> it.
>
>> How to I put the post data (eg Name=Denville, Address=Leeds)
>> into the Post command and get the return result to a String or String 
>> List
> ?
>
> Again, it depends on what the HTML looks like.
>
>
> Gambit
>
> 
Re: Indy version, Post method
#802
Author: Remy Lebeau (TeamB)
Date: Tue, 31 Jan 2006 23:55
67 lines
3381 bytes
"Denville Longhurst" <Denville@metco.co.uk> wrote in message
news:43dff36a@newsgroups.borland.com...

> OK, here is a simple, working form that illustrates what I
> want to achieve from a BCB application using Indy
> (TIdHTTP v 8.0.25)

That is a VERY VERY old version of Indy.  Indy 8 is no longer supported by
Indy's developers (including me).  You should upgrade to at least the latest
Indy 9.0.50 snapshot.

Under Indy 9 (and 10), the code would be one of the following, depending on
whether the script expects data to be posted using the "multipart/form-data"
encoding or not:

1)

    TStringList *Values = new TStringList;
    try
    {
        Values->Add("recipient=fpl@metco.co.uk");
        Values->Add("env_report=REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT");
        Values->Add("print_config=email,realname,subject");
        Values->Add("sort=order:message");
        Values->Add("print_blank_fields=1");

Values->Add("redirect=http://www.metco.co.uk/MyTemp/FplWeback1.htm");
        Values->Add("email=a.pilot@metco.co.uk");
        Values->Add("MyName=Denville");
        Values->Add("MyTown=Leeds, England");
        Values->Add("Submit=Submit");
        Memo1->Text =
IdHTTP1->Post("http://cgi.uk2.net/cgi-bin/uk2-formmail.pl", Values);
    }
    __finally {
        deleteValues;
    }

2)

    #include "IdMultipartFormData.hpp"

    TIdMultipartFormDataStream *Values = new TIdMultipartFormDataStream;
    try
    {
        Values->AddFormField("recipient", "fpl@metco.co.uk");
        Values->AddFormField("env_report",
"REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT");
        Values->AddFormField("print_config", "email,realname,subject");
        Values->AddFormField("sort", "order:message");
        Values->AddFormField("print_blank_fields", "1");
        Values->AddFormField("redirect",
"http://www.metco.co.uk/MyTemp/FplWeback1.htm");
        Values->AddFormField("email", "a.pilot@metco.co.uk");
        Values->AddFormField("MyName", "Denville");
        Values->AddFormField("MyTown", "Leeds, England");
        Values->AddFormField("Submit", "Submit");
        Memo1->Text =
IdHTTP1->Post("http://cgi.uk2.net/cgi-bin/uk2-formmail.pl", Values);
    }
    __finally {
        deleteValues;
    }


Gambit
Re: Indy version, Post method
#809
Author: Denville Longhurst
Date: Wed, 01 Feb 2006 15:57
78 lines
3664 bytes
Many thanks, particularly for your prompt and generous replies.

Denville.

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:43dff852$1@newsgroups.borland.com...
>
> "Denville Longhurst" <Denville@metco.co.uk> wrote in message
> news:43dff36a@newsgroups.borland.com...
>
>> OK, here is a simple, working form that illustrates what I
>> want to achieve from a BCB application using Indy
>> (TIdHTTP v 8.0.25)
>
> That is a VERY VERY old version of Indy.  Indy 8 is no longer supported by
> Indy's developers (including me).  You should upgrade to at least the 
> latest
> Indy 9.0.50 snapshot.
>
> Under Indy 9 (and 10), the code would be one of the following, depending 
> on
> whether the script expects data to be posted using the 
> "multipart/form-data"
> encoding or not:
>
> 1)
>
>    TStringList *Values = new TStringList;
>    try
>    {
>        Values->Add("recipient=fpl@metco.co.uk");
>        Values->Add("env_report=REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT");
>        Values->Add("print_config=email,realname,subject");
>        Values->Add("sort=order:message");
>        Values->Add("print_blank_fields=1");
>
> Values->Add("redirect=http://www.metco.co.uk/MyTemp/FplWeback1.htm");
>        Values->Add("email=a.pilot@metco.co.uk");
>        Values->Add("MyName=Denville");
>        Values->Add("MyTown=Leeds, England");
>        Values->Add("Submit=Submit");
>        Memo1->Text =
> IdHTTP1->Post("http://cgi.uk2.net/cgi-bin/uk2-formmail.pl", Values);
>    }
>    __finally {
>        deleteValues;
>    }
>
> 2)
>
>    #include "IdMultipartFormData.hpp"
>
>    TIdMultipartFormDataStream *Values = new TIdMultipartFormDataStream;
>    try
>    {
>        Values->AddFormField("recipient", "fpl@metco.co.uk");
>        Values->AddFormField("env_report",
> "REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT");
>        Values->AddFormField("print_config", "email,realname,subject");
>        Values->AddFormField("sort", "order:message");
>        Values->AddFormField("print_blank_fields", "1");
>        Values->AddFormField("redirect",
> "http://www.metco.co.uk/MyTemp/FplWeback1.htm");
>        Values->AddFormField("email", "a.pilot@metco.co.uk");
>        Values->AddFormField("MyName", "Denville");
>        Values->AddFormField("MyTown", "Leeds, England");
>        Values->AddFormField("Submit", "Submit");
>        Memo1->Text =
> IdHTTP1->Post("http://cgi.uk2.net/cgi-bin/uk2-formmail.pl", Values);
>    }
>    __finally {
>        deleteValues;
>    }
>
>
> Gambit
>
> 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads