Solved

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

Posted on 2001-09-05
9
1,468 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now