|
NetBurner 3.5.8
PDF Version |
Example Path: examples/SSL/HtmlFormPost
This example handles HTML form submissions on a NetBurner device over an encrypted HTTPS connection. It walks through a two-form, three-page workflow and echoes the collected values back on a completion page.
It is the secure counterpart of the standard examples/Web/HtmlFormPost example – the only functional difference is that the web server is started with StartHttps() and the device serves the pages with an embedded TLS certificate and private key.
UserMain() initializes the network stack and starts the HTTPS server with StartHttps().index.html presents the first form, which POSTs to form1. The form1PostCallBack() handler stores the single text field, then issues a RedirectResponse() to page2.html.page2.html presents the second form (Var0-Var3), which POSTs to form2. The form2PostCallBack() handler stores each variable, then redirects to complete.html.complete.html displays the submitted values via the <!--CPPCALL WebTextForm1 --> and <!--CPPCALL WebTextForm2 --> tags, which are filled in by WebTextForm1() / WebTextForm2() as the page is served.The post handlers are registered against wildcard URL patterns so any URL starting with form1 / form2 is routed to the matching callback:
HtmlPostVariableListCallback postForm1("form1*", form1PostCallBack);
HtmlPostVariableListCallback postForm2("form2*", form2PostCallBack);
WebTextForm1 / WebTextForm2 CPPCALL handlers.Each callback is invoked with a sequence of events:
RedirectResponse() to the next page.strncpy.EnableSystemDiagnostics() is enabled for development and would typically be removed for production.examples/Web/HtmlFormPost – the same example without SSL/TLS.