Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By noodlesuk
#58211 Hi

Hope this hasn't be covered before, didn't see anything in the search results. I have a sketch which runs a webserver, with multiple pages, using:-

Code: Select allserver.on("/", handleRoot);

Code: Select allserver.on("/config", handleConfig);


the config page has a form to submit data (via get) which is written to eeprom, an example field

Code: Select all<form method='get' action='a'><label>SSID: </label><input name='ssid' length=32><BR>"


once this form is submitted, how would I go about handling the request for the page which starts with "/a?ssid=" ? I want something that allows wildcards, as the data entered will vary, but not quite sure how to do this in code. Something like

Code: Select allserver.on("/a?ssid=***********", handleConfig)


I have seen an example where the request is monitored using an if statement, like this:-

Code: Select allif ( req.startsWith("/a?ssid=") ) {


But I wanted to use the server.on format. Any help much appreciated. :D
User avatar
By martinayotte
#58253 server.on() should point to URL only without the arguments.
Code: Select allserver.on("a", saveConfig);

Then in your new saveConfig() handler you can grab value of arguments with server.args() to get the count, server.hasArg() to figure out if arg exist (such as checkbiox), and finally server.arg() to get the values.