hi! I've been working for a while with the ethernet shield but there is a part that I can't make it work. I try to connect with a website using the POST method, but it doesn't seem to work with more than one variable. Here is the code:
void detectSensors(){
//Here we will assign the name for each sensor
String sensorname= "sensor1=office";
String sensorname2= "sensor2=showroom";
String toarray= sensorname2+"&"+sensorname;
//CREATE A TABLE FOR THIS ARDUINO WITH THE NAME OF ARDUINOTABLE
if (client.connect(myserver, 80)) {
Serial.println("Putting sensors..");
client.println("POST /my/sensors.php HTTP/1.1");
client.println("User-Agent: arduino-ethernet");
client.println("Host: www.webpage.com");
client.println("Connection: close");
client.println("Content-Type: application/x-www-form-urlencoded;");
client.print("Content-Length: ");
client.println(toarray.length());
client.println();
Serial.println(toarray);
client.stop();
Serial.println("Yes!! sensors put");
}
else {
Serial.println("connection failed, sensors not put...");
Serial.println();
}
}
If I do with only one variable I find no problem, and the website reads the POST perfectly, when I put two, I can connect to the website but there is no readable POST...Any suggestion?