Home |
Form Action Posts |
Form Action PostsForms allow the browser to send input back to the server. This feature is useful if there are commands or specific settings that need to be sent to the server. A Form Action Post consists of keywords in the web page which instruct the browser to send a POST command back to the Web server. The command sent back is based upon input from the browser side. Upon receipt of the POST command, the Web server will call a user supplied function that parses input from the browser and performs an action based on what it found in the input. The function xn_line_get can be called to retrieve the input data to be parsed. Form Action Posts are implemented in the Web server via one or more user-supplied tables of names and function pointers which reference callback functions of type post_function_entry. Such tables can be passed the the Web server at program initialization through function http_add_post_functions. Example:static struct post_function_entry my_post_functions[] = { {"form_demo.fn", form_demo }, {"", END_OF_TABLE} }; http_add_post_functions(my_post_functions); When the Web server encounters a reference to a function call in an action attribute of a form on a HTML page such as: <form name="FormDemo" action="form_demo.fn" method="post"> ... </form> it will scan the table for the given function name. In this example, "form_demo.fn" is the first entry and the corresponding function form_demo() is called. Function form_demo() can then read the posted data from the browser using function xn_line_get and send confirmation data to the browser using function xn_line_put. Note that the confirmation data must be preceded by "\r\n" to be correctly parsed by all browsers. Please note that POST function handlers are executed in the context of the Web server thread which does not maintain a floating point context. If the handler contains floating point calculations, it must first call function RTKProtect8087. See demo program WebServer for a complete example of Form Posts.
|