I think this is what you wanted?
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
/* Set these to your desired credentials. */
const char *ssid = "ESP8266";
const char *password = "thereisnospoon";
char inString[32] ; // string for incoming serial data
int stringPos = 0 ; // string index counter // what do you use this for?
boolean startRead = false ; // is reading?
ESP8266WebServer server(80);
WiFiClient client;
/* Go to http://192.168.4.1 in a web browser
* connected to this access point to see it.
*/
void webpage() {
server.send(200, "text/html", "<html><body><form name='frm' method='post'><input type='text' name='x' ><input type='submit' value='Submit'> </form></body></html>");
}
void response(){
if(server.hasArg("x") && (server.arg("x").length()>0)){ // TODO check that it's not longer than 31 characters
Serial.print("User entered:\t");
Serial.println(server.arg("x"));
inString = server.arg("x");
server.send(200, "text/html", "<html><body><h1>Successful</h1><a href='/'>Home</a></body></html>");
} else {
server.send(400, "text/html", "<html><body><h1>HTTP Error 400</h1><p>Bad request. Please enter a value.</p></body></html>");
}
}
void setup() {
Serial.begin(9600);
Serial.println();
Serial.println("Configuring access point...");
Serial.println();
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.println("AP IP address: ");
Serial.println(myIP);
server.on("/",HTTP_GET, webpage);
server.on("/",HTTP_POST,response);
server.begin();
Serial.println();
Serial.println("HTTP server started");
}
void loop() {
server.handleClient();
}
I changed the method to POST, so that you can differentiate between the request of the form page, and the submitting of the form.