Chat freely about anything...

User avatar
By Piergiusepp1996
#75896 Hy guys, I crated a server on my esp and the HTML code is this:

<label for="ssid"><b>SSID</b></label>
<input type="text" placeholder="Enter SSID" name="ssid" required>

<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>

<button type="submit">Invia</button>

I need to save what I write in ssid and psw form in a local variable (char*) called SSID and password.
How can I do that?
Thanks to all
User avatar
By svideo
#75940 Because you're going to allow the user to enter data you are going to need to start with allocating enough room in your char for the SSID and password. Try something like this for defining those values:

Code: Select allchar wifiSSID[33] = "defaultssid";
char wifiPass[64] = "defaultpass";

To prevent problems you might want to use the "maxlength" HTML tag on your inputs, like this:
Code: Select all<input type="text" placeholder="Enter SSID" name="ssid" required maxlength="32">
<input type="password" placeholder="Enter Password" name="psw" required maxlength="63">

Finally, to grab those values in the handler function for this page, do something like the following:
Code: Select allserver.arg("ssid").toCharArray(wifiSSID, 33);
server.arg("psw").toCharArray(wifiPass, 64);