-
Notifications
You must be signed in to change notification settings - Fork 10
chl_posti
it4e edited this page Apr 17, 2016
·
2 revisions
<chl/chl.h>
chl_posti, CHL POST integer
int chl_posti(char * name);
The chl_posti function is used to fetch the value converted to an integer of the POST method variable [name].
- name: the name of the POST variable
On success: POST variable value converted to integer, -1 if variable is not defined, if conversion to integer could not be done or if an error occurred.
Call CHL controller file 'index.chl' with POST parameters (num1=40, num2=10)
POST index.chl HTTP/1.1
num1=40&num2=10
main.c
#include <chl/chl.h>
#include <stdio.h>
int main() {
int sum;
chl_set_default_headers();
chl_print_headers();
sum = chl_posti("num1") + chl_posti("num2");
printf("The sum of %s + %s = %d", chl_post("num1"), chl_post("num2"), sum);
}
Output: The sum of 40 + 10 = 50