Send data using HTTP POST to php script
Posted: Tue Mar 17, 2009 9:47 pm
Hi,
My set up is following-
1. I have a device which will connect to server and send data using HTTP POST. It can be programmed using python.
2. When php server will receive that data through POST request from the client device, it will process data and save it to database.
My problem is in communication where I send the data from device using the POST method above but in server side I don't receive any data. So, what may go wrong?
I believe problem may be in 2 places-
1. I am either making mistake in POST method.
2. Or, my server side script is wrong.
I am also testing it using telnet to my localhost.
My POST method is the following-
And server side script is the following-
Where is the problem? Shouldn't I use $_POST? Or, do I need a custom function to fetch data from the POST method above?
Now, please suggest me a simple POST method and PHP script that works.
Thanks.
My set up is following-
1. I have a device which will connect to server and send data using HTTP POST. It can be programmed using python.
2. When php server will receive that data through POST request from the client device, it will process data and save it to database.
My problem is in communication where I send the data from device using the POST method above but in server side I don't receive any data. So, what may go wrong?
I believe problem may be in 2 places-
1. I am either making mistake in POST method.
2. Or, my server side script is wrong.
I am also testing it using telnet to my localhost.
My POST method is the following-
Code: Select all
POST /insert.php HTTP/1.1
Host: http://www.mysite.com
Content-Type: text/plain; charset=iso-8859-1
Content-Length: 10
data=1234567890
Code: Select all
<?php
$str = $_POST['data'];
echo $str;
?>
Now, please suggest me a simple POST method and PHP script that works.
Thanks.