Solved

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

Posted on 2001-09-05
9
1,478 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
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 …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

806 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