SynopsisCreate a GoForm™ procedure. Prototype#include "webs.h" int websFormDefine(char_t *urlPrefix, void (*formHandler)(webs_t wp, char_t *path, char_t *query)); Parameters
DescriptionThe websFormDefine procedure is used to create a GoForm™ procedure. It establishes the nominated formHandler procedure as the handler for all URLs that begin with "/goform/ urlPrefix". The GoForm processor GoForms provide a standard Common Gateway Interface (CGI) implemented as an in-memory forms processor. GoForms procedures run in-memory without creating a new process for each browser connection. By sharing the address space with the GoAhead WebServer, GoForms procedures can directly access the full request context. The GoForm handler also automatically decodes and parses all POST and query data for easy access. A convenient API (see websGetVar) permits easy access to CGI variables. In addition to POST and query data, the standard CGI variables are also defined. GoForm procedures can access the URL path via the path parameter which holds URL segment after the host name and port number. The full POST data or query string is passed in the query variable from conform to the following prototype: void myForm(webs_t wp, char_t *path, char_t *query){ websHeader(wp); websWrite(wp, "Name %s", websGetVar(wp, "name", "")); websWrite(wp, "Age %s", websGetVar(wp, "age", "")); websFooter(wp); websDone(wp, 200); } The GoForm procedure is responsible for writing the HTTP header and HTML document contents back to the user's browser. websHeader creates a standard HTTP header with initial HTML tags. websFooter closes the document with a closing HTML tag. Inside the GoForm procedure, websGetVar, websRedirect, websWrite, and websWriteBlock are some of the most useful API calls. Return ValueReturns 0 if the GoForm procedure is successfully defined, otherwise -1 is returned. Examplevoid myForm(webs_t wp, char_t *path, char_t *query) { websHeader(wp); websWrite(wp, "Name is %s, Address %s", websGetVar(wp, "name", "")); websDone(wp, 200); websFooter(wp); } websFormDefine("myForm", myForm); Stability ClassificationStable. See AlsoActive Server Pages, JavaScript, URL Handlers, websDone, websFooter, websGetVar, websHeader, websSecurityHandler, websUrlHandlerDefine, websWrite |