HTML "form" in arduino to "GET" the connected device's user input data.

Hello fellow arduino-ers ,

I am currently using a WeMos D1 R2 (the ESP8266 module) and I want to use it to set up a webpage in which the user enters data through a form (using GET) and the data is sent back to the board . Then the board executes the other desired functions from the GET data… I have been searching about it for a week now , any help would be greatly appreciated… (Sidenote: Thw WeMos acts as an AP ) :slight_smile:

AND can anyone tell the problem in the attached sketch ? ( It shows "‘class ESP8266WebServer’ has no member named ‘available’ ")… That’s about it… Thanks…

#define MaxHeaderLength 16 

#include <ESP8266WiFi.h>
#include <WiFiClient.h> 
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>

/* Set these to your desired credentials. */
const char *ssid = "thenetwork";
const char *password = "password";

ESP8266WebServer server(80);
String HttpHeader = String(MaxHeaderLength); 

/* Go to http://192.168.4.1 in a web browser
 * connected to this access point to see it.
 */

void handleRoot() {
  server.send(200, "text/html", "<html><body><form  name='frm' id='frm' method='get'>");
  server.send(200, "<input type='text' name='inc' ><input type='text' name='n'><input type='submit' value='Submit'></form>");
  server.send(200, "<SCRIPT TYPE='text/JavaScript'>.function mf(){document.getElementById('frm').submit;}</SCRIPT></body></html>");
}
void blink(){
    digitalWrite(BUILTIN_LED, LOW);
    delay(200);
    digitalWrite(BUILTIN_LED, HIGH);
    delay(200);
  }

void setup() {
  pinMode(BUILTIN_LED, OUTPUT);
  delay(1000);
  Serial.begin(9600);
  Serial.println();
  Serial.print("Configuring access point...");
  Serial.println();
  WiFi.softAP(ssid, password);

  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  server.on("/", handleRoot);
  server.begin();
  Serial.println();
  Serial.println("HTTP server started");
  
}

void loop() {
  server.handleClient();
  
  WiFiClient client = server.available();

  if (client) {
    while (client.connected()) {
       if (client.available()) {

         char c = client.read();
            if (HttpHeader.length() < MaxHeaderLength)
            {
               HttpHeader = HttpHeader + c;
            }
            if (c == '\n') {
           Serial.println(HttpHeader);
  blink();                  
 
}

d1r2project.ino (1.72 KB)

(deleted)