Solved

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

Posted on 2001-09-05
9
1,447 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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