Solved

DELPHI (NMHTTP) -> POST -> PHP-script output

Posted on 2001-09-05
9
1,497 Views
Last Modified: 2010-04-06
Hello,

I wrote an delphi application, that send via NMHTTP
data to the php-script (internet).

The PHP-Script should use this variables, for example
i send an string "test=abc"  the script should output
abc  ( echo $test)

But the variable is empty. When I send it via ?test=abc  the output is right. The POST via Delphi's NMHTTP don't work as I want ...

can anyone help me - I can't access to the post-variables via php.

Thanx
Andy
0
Comment
Question by:andys79
  • 6
  • 2
9 Comments
 
LVL 26

Expert Comment

by:EddieShipman
ID: 6465631
Try dumping the buggy Net Masters component and downloading
Indy from http://www.nevrona.com.

Use the TIdHTTP component to do the same.
0
 

Author Comment

by:andys79
ID: 6491360
I don't need an commercial product for 100 things - when I need just one feature. Do anyone have a better solution?
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 6491674
First...

It is not a commercial product. It is free, included with Delphi6 and also downloadable from
http://www.nevrona.com/indy for other Delphi versions.

Can you show the code you are using?

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Accepted Solution

by:
EddieShipman earned 100 total points
ID: 6491735
I found this using a search on http://www.tamarcka.com. Give it a try.

In viewing the content of your response, you will notice
that NMHTTP encoded your postdata like this: test%3Dabc

The reason you are getting
"Content1%3DXXXX%3FContent2%3DYYYY" is that TNMHTTP is
obviously mime-encoding your string before it is sent.

There's not much you can do about that, particularly as
the source for TNMHTTP isn't given away, unlike the rest
of the VCL.

I've only ever done this in file mode. What you need to do
in that case is to change the call to Post as follows:

NMHTTP1.Post('http://mydomain/scripts/cgiexample.exe','testfile.htm');

where OutputFileMode is True. Then you need to create a
file 'testfile.htm' which contains something like:

--SimpleAGB
Content-Disposition: Form-Data; Name="Content1"
Content-Type: Text/plain
XXXX
--SimpleAGB
Content-Disposition: Form-Data; Name="Content2"
Content-Type: Text/plain
YYYY
--SimpleAGB--

The tricky thing is that you then need to add to the
output headers the line:

Content-Type: multipart/form-data; Boundary=SimpleAGB

This you can do by catching the OnAboutToSend event of
TNMHTTP and altering the Content-Type header:

  NMHTTP1.SendHeader.Values['Content-Type'] := 'multipart/form-data;
Boundary=SimpleAGB';
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 6491757
Also...

It's my understanding that you need to explicitly
configure a server to accept POSTs. There are some
security concerns involved here. You don't want your
server to accept data that you are not looking for!


0
 

Author Comment

by:andys79
ID: 6499523
I will try it today - and feedback you tomorrow.
Thx4help

Andy
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 6611090
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 6611091
0
 
LVL 17

Expert Comment

by:geobul
ID: 9295443
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

accept EddieShipman's comment as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Thanks,

geobul
EE Cleanup Volunteer
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question