Sending Data to a Mysql WebServeur using POST method

Royalldonkey, and others: I continued to play with this, using the code from zoomkat to build something that would POST as you were POSTing. I came up with this, which does work -- with a caveat (see below):

//zoomkat 9-22-12
//simple client test
//for use with IDE 1.0.1
//with DNS, DHCP, and Host
//open serial monitor and send an e to test
//for use with W5100 based ethernet shields

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 
  0xAA, 0xBB, 0xCC, 0xDD, 0xEF, 0x02 };  // Arduino MAC address
byte ip[] = { 
  192, 168, 0, 11 };  // Arduino IP address
byte server[] = { 
  192,168,0,13 }; // Directly address the web server
char serverName[] = "localhost.at-home";  // If used, will initiate a DNS lookup of web server
//String response;

EthernetClient client;

//////////////////////

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    while(true);
  }

  Serial.begin(9600); 
  Serial.println("Even better client test 02/03/13"); // so I can keep track of what is loaded
  Serial.println("Send a g to GET or a p to POST in serial monitor to test"); // what to do to test
}

void loop(){
  // check for serial input
  if (Serial.available() > 0) //if something in serial buffer
  {
    byte inChar; // sets inChar as a byte
    inChar = Serial.read(); //gets byte from buffer
    switch (inChar) {  // checks to see byte is an e
      case 'e': // Backwards compatibility
      case 'g': sendGET(); // call sendGET function below when byte is an e (or g)
                break;
      case 'p': sendPOST(); 
                break;
    }
  }  
} 

//////////////////////////

void sendGET() //client function to send/receive GET request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /arduino.php?test=data HTTP/1.0"); //download text
    client.println("Host: localhost.at-home");
    client.println(); //end of get request
  } 
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor 
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}//////////////////////////

void sendPOST() //client function to send/receive POST request data.
{
  if (client.connect(serverName, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    
    Serial.println("POST /arduino.php HTTP/1.1"); //download text
    Serial.println("From: Arduino1");
    Serial.println("Host: localhost.at-home");
    Serial.println("User-Agent: HTTPTool/1.1");
    Serial.println("Connection: close");
    Serial.println("Cache-Control : no-cache");
    Serial.println("Pragma: no-cache");
    Serial.println("Expires: -1");
    Serial.println("Content-Type: application/x-www-form-urlencoded");
    Serial.print("Content-Length: ");
    Serial.println(31);
    Serial.println();
    Serial.println("data=ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    Serial.println();

    client.println("POST /arduino.php HTTP/1.1"); //download text
    client.println("From: Arduino1");
    client.println("Host: localhost.at-home");  // Will be needed if apache is configured for VHOSTS
    client.println("User-Agent: HTTPTool/1.1");
    client.println("Connection: close");
    client.println("Cache-Control : no-cache");
    client.println("Pragma: no-cache");
    client.println("Expires: -1");
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.print("Content-Length: ");
    client.println(31);
    client.println();
    client.println("data=ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    client.println();

    Serial.println("ARDUINO: HTTP message sent");
    delay(3000);
    if(client.available())
    {
      Serial.println("ARDUINO: HTTP message received");
      Serial.println("ARDUINO: printing received headers and script response...\n");

      while(client.available())
      {
        char c = client.read();
        Serial.print(c);
      }
    }
    else
    {
      Serial.println("ARDUINO: no response received / no response received in time");
    }

    client.stop();
  } 
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
    Serial.print(c); //prints byte to serial monitor 
  }

  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop(); //stop client

}
/* arduino.php

<?php
	echo "hello there\r\n";
	
	foreach ($_POST as $key => $value) {
		
		echo "$key=$value\r\n";
	}
?>

*/

What I could never do was talk to a webserver on the same subnet as my Arduino. It has to be a configuration issue, but I can't figure it out. I have my Arduino on 192.168.0.11 and webserver on 192.168.0.13. The Arduino never connects to it. If I simply change the address of the webserver to 192.168.100.1, it works like a champ. If I use a serverName and reference something outside my local network, it works fine.

So other than that, my POST above should do what you are trying to do.

I hope someone can chime in a explain the wierdness with same-subnet connections. I have verified the webserver is running and working. It is just a normal apache 2.2 server. Deep inspection of the code and the WireShark traces shows me the wiznet library simply never talks to the same-subnet server.