Hi! i recently bought an ethernet shield for my arduino and have tested it via the webclient example. Now it says it has connected when it try client.connect(server, 80); but when i try to run a webpage with client.println(); it doesn't work. When i go to my webpage via the browser it does work, so the PHP code is fine. I tried to find the solution with Google but no luck yet.
The idea is that the arduino just tells the webpage to run and the webpage does some stuff with PHP and a database, i don't have to return anything to the arduino script.
My question is am i doing this the right way or should i approach it differently, like with processing?
This is the code i have now:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xC0, 0x1F };
char server[] = "http://www.signtec.nl";
EthernetClient client;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}
delay(2000);
if (client.connect(server, 80)) {
Serial.println("connected"); // The serial shows 'connected'
// This doesn't seem to run my webpage
client.println("POST /?q=test HTTP/1.1");
client.println("Host: www.signtec.nl");
client.println("User-Agent: Arduino");
client.println("Connection: close");
}
else {
Serial.println("connection failed");
}
}
void loop() {
}