I am trying to send a name variable from my ESP8266 to index.php.
This is my arduino code:
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <HTTPClient.h>
const char* ssid = "NikitaiPhone"; //replace with your own wifi ssid
const char* password = "Maxius1"; //replace with your own wifi ssid password
const char* host = "104.220.131.254";
WiFiClient client;
void setup() {
Serial.begin(115200);
delay(10); // We start by connecting to a WiFi network Serial.println();
Serial.println();
WiFi.mode(WIFI_OFF);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop(){
HTTPClient http;
http.begin(client, "http://104.220.131.254/index.php?name=Joe");
int httpCode = http.GET();
String payload = http.getString();
Serial.println(httpCode);
Serial.println(payload);
http.end();
delay(5000);
}
This is my php code:
<?php
$name = $_GET['name'];
if($name == "Joe"){
echo "name " . $name;
} else {
echo "name none";
}
?>
This is the response from index.php?name=Joe
This is the response from index.php
I am trying to have the name displayed on index.php. How do I do that? I would like to send variables from one ESP8266 to the index.php page and have the other ESP8266 read them. However, if I can only send it to index.php?name=Joe, there is no way for the other ESP8266 to read that page.
Thanks