w5100 send measurements to web server via post method

Hello,

I am trying two hours now to send some measurements over the web but can't make it happen. I use arduino uno and I read from one analog input the measurements. I am sure I have mistakes in the client.println section of the code because when I go to the site all I get from apache is this:

Notice: Undefined index: measurements in panel_update.php on line 4 where line 4 is : echo $_GET["consumption"];

I was searching for examples and thought that the webclientrepeating example

    client.println("GET /latest.txt HTTP/1.1");
    client.println("Host: www.arduino.cc");
    client.println("User-Agent: arduino-ethernet");
    client.println("Connection: close");
    client.println();

will solve my questions but didn't had some chance. Can someone help me out with my case? What should I have in the client.println ? I only want one variable to be send and it's declared above all as double measurements; Thank you!

Two approaches for the client POST headers:

client.println("POST hxxp://yourdomain.com/SMSSite/XMLInterface/Postxml.aspx HTTP/1.0");
// add a header indicating you have content-data to send.  If you set this too low, the server won't see it.  If it is too high, the server may wait, or report an error.
client.print("content-length: ");
client.println(strlen(big_string));
// tell the server you are done with the header.
client.println();
// send the posted data.
client.print(big_string);
    client.print("POST /formResponse?formkey=");
    client.print(formkey);
    client.println("&ifq HTTP/1.1");
    client.println("Host: spreadsheets.google.com");
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.println("Connection: close");
    client.print("Content-Length: ");
    client.println(data.length());
    client.println();
    client.print(data);

Thank you for the reply zoomkat, but what am I supposed to have in data variable? If I understand right, my formkey is the consumption variable but data is for what? Excuse me for my ingorance.

First have a look at the example on this page, to see how to POST values from an HTML form.
http://www.w3schools.com/php/php_post.asp

The magic HTML runes to include your own values in the POST content

<input type="hidden" name="myVariableName" value="myValue" />

I know how POST method works but can’t receive the variables.
That’s a piece of code inside my loop

String  main_data = "measurement=" + analogValue;
client.println("POST /panel/panel_update.php HTTP/1.1");
client.println("Host: 192.168.2.6");
client.println("Content-Type: application/x-www-form-urlencoded");
client.println("Connection: close");
client.print("Content-Length: ");
client.println(main_data.length());
client.println();
client.println(main_data);
client.println();
delay(2000);
client.stop();

As you see, I try to make it happen with my local server but nothing.
The panel_update.php has the following:

<?php
if (isset($_POST['measurement']))
{
echo $_POST['measurement'];
}
else
{
echo "hi!";
}
?>

I keep getting the hi! message. What am I doing wrong? The input tag you suggest, where exactly should be placed?
Thank you.

EDIT

I have checked, via wireshark, the incoming packets I receive from the ethernet shield and I do have, between many others, packets with POST flag and the variable measurement. So, as I see, the error must be somewhere in my panel_update.php because the shield does really send the information. In the panel_update.php, all I have are these lines of code:

<?php
if (isset($_POST['measurement']))
{
echo $_POST['measurement'];
}
else
{
echo "hi!";
}
?>

But, what’s going wrong and I get all the time the hi message?

post the raw packet or save it and attach.... any reason why you're not using /GET might be easier...

I selected a packet with POST information and followed the tcp stream from wireshark's options. Surprisingly, I do receive the measurement as shown below

POST /panel/panel_update.php HTTP/1.1

Host: 192.168.2.6

Content-Type: application/x-www-form-urlencoded

Connection: close

Content-Length: 17



measurement=30.81



HTTP/1.1 200 OK

Date: Sun, 09 Jun 2013 15:26:48 GMT

Server: Apache/2.4.2 (Win32) OpenSSL/1.0.1c PHP/5.4.4

X-Powered-By: PHP/5.4.4

Set-Cookie: PHPSESSID=09hv89qopikk3cabphet4ttk66; path=/

Expires: Thu, 19 Nov 1981 08:52:00 GMT

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

Content-Length: 33

Connection: close

Content-Type: text/html



updateValue([{"measurement":"30.81"}]);

I just noticed it but when I hit on panel_update.php I get this error: Notice: Undefined index: measurement in C:\xampp\htdocs\panel\panel_update.php on line 8

If I understand right, when I hit on the panel_update.php I get this error because that time the shield doesn't send anything, maybe? Anyway, all I want to have as output to the panel_update.php is a json-like format of

updateValue([{"measurement":"30.81"}]);

so to fetch the measurement value and post it via javascript to panel.php How can I make it happen?