Chat freely about anything...

User avatar
By Stévanovich
#51522 Hello,
I will try to explain what i would like to to .
Fisrt , i have a ssid setting sheet wich is called and store on esp8266/data/ssid_connect.html
When i display this sheet, i enter ssid and password and send my form (post) to esp8266/

Code: Select allserver.on ( "/ssid_connect.html", handleTest );


Code: Select allvoid handleTest() {
  String tmp;
  tmp += "<HTML><HEAD><TITLE>WiWiRe VALIDATION</TITLE>";
  tmp += "<script>function redirForm() {document.myform.action = '/data/ssid_connect.html';document.myform.submit();}</script>";
  tmp += "</HEAD><BODY onLoad='redirForm()'>";
  tmp += "<FORM NAME='myform' METHOD='POST'>";
  tmp += "<INPUT TYPE='hidden' NAME='email' VALUE='youpi@free.fr'>";
  tmp += "<INPUT TYPE='hidden' NAME='password' VALUE='passyoupi'>";
  tmp += "</FORM></BODY></HTML>";
  server.send ( 200, "text/html", tmp );
}


i know i can get post value with this kind of code :

Code: Select all String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += ( server.method() == HTTP_GET ) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for ( uint8_t i = 0; i < server.args(); i++ ) {
    message += " " + server.argName ( i ) + ": " + server.arg ( i ) + "\n";
  }


NOW, i would like , in handleTest, to display again /data/ssid_connect.html , with fill in all data i already received.
But i am not agree with using get method form.

Have you any kind of idea to do this, and, is this possible ? :?:
User avatar
By martinayotte
#51556 This is not ESP related, but HTML basics !
The whole thing here is that you over-complexify your POST handling with the following :

Code: Select all<script>function redirForm() {document.myform.action = '/data/ssid_connect.html';document.myform.submit();}</script>


You should have a plain GET from that will have simple new URL for the POST, and handle it with another server.on("/data/ssid_connect_post.html")

Code: Select alltmp += "<FORM NAME='myform' METHOD='POST' action='/data/ssid_connect_post.html'>";


For your template from filled with saved values, you don't have much other ways to do it...