Skip to content
it4e edited this page Apr 17, 2016 · 3 revisions

Name

<chl/chl.h>

chl_postf, CHL POST float

Declaration

float chl_postf(char * name);

Description

The chl_postf function is used to fetch the value converted to a float of the POST method variable [name].

Arguments

  • name: the name of the POST variable

Return value

On success: POST variable value converted to float, -1 if conversion to float could not be done or an error occurred.


Examples

Call CHL controller file 'index.chl' with POST parameters (num1=40.2, num2=10.8)

POST index.chl HTTP/1.1

num1=40.2&num2=10.8

main.c

#include <chl/chl.h>
#include <stdio.h>

int main() {
    float sum;

    chl_set_default_headers();
    chl_print_headers();
    
    sum = chl_postf("num1") + chl_postf("num2");
    printf("The sum of %s + %s = %f", chl_post("num1"), chl_post("num2"), sum);
}

Output: The sum of 40.2 + 10.8 = 51

As CHL is open-source, people are able to contribute with their own APIs, plugins and code which means that CHL is constantly upgraded and provided with new features. Do you have an idea for a new CHL feature and want to contribute?

See contribute.

Setup. API. Tutorial. Examples. FastCGI.

Clone this wiki locally