473,385 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to return data using POST

I have a vendor sending me a text file using POST. I have a PHP program
receiving the data that works. I need to in the same stream return an answer
via POST. How do I send that POST in the same stream?

A snip from the code for the output portion:

$LINKOUT = implode('', file($LINKFILE . '.out'));

$LOUT = array(
'http'=>array(
'method'=>"POST",
'header'=>"Content-type: application/x-www-form-urlencoded\r\n" .
"Content-length: " . strlen("$LINKOUT"),
'content'=>"$LINKOUT"
)
);
$context = stream_context_create($LOUT);

Thanks
Gary Quiring

Jul 17 '05 #1
5 5008
Gary Quiring wrote:
I have a vendor sending me a text file using POST. I have a PHP program
receiving the data that works. I need to in the same stream return an
answer
via POST. How do I send that POST in the same stream?


You seem to be describing something which isn't HTTP - in HTTP, the client
opens a socket to the designated port (default 80) on the server, sends a
request which is usually POST or GET (but can be other things to). The
server responds with some response headers and optionally some content. If
you want to initiate a POST from the server then it must initiate a new
connection _as_ a client.

If you merely want to make some response to the POST....just output
something to the browser:
print (count($_POST) ? "Thanks,...got it\n" : "eh ? Nothing sent\n");

POST and GET are semantically and functionally different in HTTP but, apart
from the fact they are stored in seperate variables, are no different from
the point of view of PHP (except when uploading files - because HTTP only
allows that via POST).

HTH

C.

Jul 17 '05 #2
*** Gary Quiring wrote/escribió (Thu, 12 May 2005 10:20:29 -0400):
I have a vendor sending me a text file using POST. I have a PHP program
receiving the data that works. I need to in the same stream return an answer
via POST. How do I send that POST in the same stream?


As far as I know it's impossible. HTTP is a stateless protocol that has
client-server design. If your vendor's HTTP client contacts your HTTP
server, you cannot use that same connection to invert roles an make your
server act as client and viceversa.

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #3
Gary Quiring <gq******@msn.com> wrote:
I have a vendor sending me a text file using POST. I have a PHP program
receiving the data that works. I need to in the same stream return an answer
via POST. How do I send that POST in the same stream?


You can't, this is simply not how http works.

The client opens a connection, sends headers (in your case a POST) and
data (the file). When it's finished sending you can send back anything
you like using normal output functions like echo/print/whatever (in your
case the header and content from the http hash). And then close the
connection (or accept another request if keep-alive is enabled).

Jul 17 '05 #4
On Thu, 12 May 2005 16:05:19 +0100, Colin McKinnon
<co**************@andthis.mms3.com> wrote:
Gary Quiring wrote:
I have a vendor sending me a text file using POST. I have a PHP program
receiving the data that works. I need to in the same stream return an
answer
via POST. How do I send that POST in the same stream?


You seem to be describing something which isn't HTTP - in HTTP, the client
opens a socket to the designated port (default 80) on the server, sends a
request which is usually POST or GET (but can be other things to). The
server responds with some response headers and optionally some content. If
you want to initiate a POST from the server then it must initiate a new
connection _as_ a client.

If you merely want to make some response to the POST....just output
something to the browser:
print (count($_POST) ? "Thanks,...got it\n" : "eh ? Nothing sent\n");

POST and GET are semantically and functionally different in HTTP but, apart
from the fact they are stored in seperate variables, are no different from
the point of view of PHP (except when uploading files - because HTTP only
allows that via POST).

HTH

C.

Ok I was not sure what to do. They do not have a spec and I have never done any
HTML or PHP before. It's all new stuff to me. In the past everyone was happy
sending via FTP and for some reason there is a 'rush' of new 3rd party software
houses that refuse to use anything but http to send some data.

Gary

Jul 17 '05 #5

Gary Quiring wrote:
I have a vendor sending me a text file using POST. I have a PHP program receiving the data that works. I need to in the same stream return an answer via POST. How do I send that POST in the same stream?


Go to www.php.net/curl and look at the second comment. That should
answer your question.

Ken

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Pete Mahoney | last post by:
I am trying to 'POST' values from a form in a ASP file that has anonymous access permissions. I can retrieve the form values when I redirect to this page from another page which has also has...
7
by: zalzon | last post by:
Is it good practice in C++ for a member function to return data or is it better that data is stored in private member variable and printed in the member function? should i be using int...
4
by: davidfahy | last post by:
Hi all How can I transfer user to another server using POST. The problem is that Server.Transfer (preserves form data) works just in current server. Response.Redirect - uses GET method. However...
10
by: Trammel | last post by:
Hi, Im just about to start developing a new website for personal / friend use that may be accessed by other people all over the web. I was sitting thinking through designs for the pages, etc when...
6
by: Boldgeek | last post by:
I am trying to develop an app that will allow automatic updating of a web form which uses multipart/form-data enctype (as it MIGHT be sending an image) I have an example form, which when...
1
by: paulsubha | last post by:
Hi All I am submitting a form using POST data,I have to get data(hidden parameters) in the Javascript.Is there any method available to get the data.
2
by: ajaxcoder | last post by:
Hi In my project i had a login form and i am trying to send the username and password to the server for authentication using xmlHttpRequest. Hence i am using POST request but i am unable to send...
2
by: runway27 | last post by:
i am presently passing the value of a variable to a php file using GET after data has been inserted to the database. ex= $firstname = $_POST; if(!$sqlconnection) { echo "error message"; }
2
by: ajmerasunny | last post by:
Hi, I have following task to implement: I have to pass username and password from first html page to second html page using POST Method and automatically submit the second html page on loading....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.