Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP post headers

Status
Not open for further replies.

mmills1

Programmer
Apr 8, 2010
18
GB
Hi, I am trying to get my server to accept a cgi file that is being automatically sent.

Once the connection is successful i would like to save the file or post the details onto a PHP page on the server.

I have manage to GET the file using GET headers but the data will be sent across after something has changed, so I cannot just keep refreshing the page every 5 seconds.

If I were to use POST headers in the cgi file can I pick up that data on a webpage??If so how?

I have heard of CURL but think I will have issues installing it on PHP4.

help?
 
could you be a lot more precise about the setup you are using?

where does the cgi program reside?
where is it getting its data?
how is it being called?
what does the cgi do?


when you say 'post the details onto a php page on the server' what do you mean? php tends to interact with users via a webpage and servers cannot instantiate a web page for a client.
 
The device im am using is called a netiom, It acts pretty much like a switch, when one is turned on it outputs a 1 when its turned off its outputs a 0.

It can also has a built in web server so I can use as a server or client.

I can enter an IP and a port number, using an interface but thats pretty much all i can do with it. As well as uploading the files needed such as the client.cgi

When the switch changes it sends a file called client.cgi to the server? When i have looked at the data being sent in wireshark it just sends the contents of the file, of which my apache server replys with a bad request. In the apache error log it says: cannot read headers.

So the data contained in the client.cgi file will be the output which i can save as a PHP variable and pass it to the server. Then either save it to a database or file. Then output that data to another web page.


Not sure how the device calls the cgi file to send it.

Hope this makes it a bit more clear.
 
i would be totally gobsmacked if your switch sent a cgi file to a remote server. cgi normally resides on the remote server and the remote webserver passes data that it receives to the cgi script and then does something with the resulting output data.
 
Well the device can be used as a server? it definatly passes data to the client.cgi file, and im sure it is being sent to my server it is on the same LAN network.

How would you would your normally post data to another webpage without using a submit on a form?
 
so you want to pass POST data to the embedded device, which will in turn pass data to the cgi script that sits on the embedded device? that is different to the previous post in which you said 'it sends a file called client.cgi to the server'.

if you want to use php to do this use cURL.

but I still don't think you have adequately precised the flows you want to achieve.

I am assuming that you want to use the netiom as a client in response to certain events. that seems possible.

you check the 'enable client box' and specify the IP address and port of the server to which you want to connect.

if the event is triggered, the netiom will process the file called client.cgi and send the output of that file to the remote server. again, that is not a problem. and not a problem if you want the receiving script to be a php script.

without a detailed study of the netiom manual I have no idea what form the data will take so I suggest you run some tests with the following as the receiving script

Code:
<?php
file_put_contents(print_r($_REQUEST, true));
?>
you can then look at the shape of the incoming data and work out what you want to do with it.

at this point, I'm stuck. what do you want to do next?

 
if the event is triggered, the netiom will process the file called client.cgi and send the output of that file to the remote server. again, that is not a problem. and not a problem if you want the receiving script to be a php script. "

That is exactly what i want to do. I will run some tests and see what i can get across cheers.

"so you want to pass POST data to the embedded device, which will in turn pass data to the cgi script that sits on the embedded device"

This is wrong the device automically will send the details to the client cgi.

if i wrote %5 in the client.cgi file it wouldoutput 1110111 for example.

Cheers for you help.
 
mistake

Code:
<?php
file_put_contents('mydebugfile.txt', print_r($_REQUEST, true));
?>
 
I keep getting:

Call to undefined function: file_put_contents()

I am running on PHP version 4??Dont think it works with that??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top