Hello guys,
I've searched the forum how to send data via arduino to a PHP page , but I ended up not find the error that prevents me from completing this task , looking at the code I'm using, someone can point to me
the problem in the code, because it does not work.
#include <Ethernet.h>
#include <SPI.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x2A, 0x8D };
byte ip[] = { 192, 168, 0, 77 };
byte server[] = { 127, 0, 0, 1 };
EthernetClient client;
float var;
void setup() {
Serial.begin(115200);
Ethernet.begin(mac, ip);
var = 20;
}
void loop(){
Serial.println(client.status());
if(client.connect(server,80))
{
Serial.println(client.status());
client.println("GET /arduino/index2.php HTTP/1.1");
client.println("Host: 127.0.0.1");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print(var);
}
else
{
Serial.println("Connection unsuccesful");
}
if (client.connected()) {
client.stop(); // DISCONNECT FROM THE SERVER
}
}
Thanks in advance