Solved

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

Posted on 2001-09-05
9
1,510 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month7 days, 19 hours left to enroll

617 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