A C Example
This is a simple example of a form handling program written in C. It accepts user input submitted through a form, and prints the values that the user entered. The source code for the program appears in Listing 11.2.
Listing 11.2. A Sample CGI Program Written in C
1: #include <stdio.h> 2: #include "cgic.h" 3: 4: void print_name(); 5: void print_secure(); 6: void print_operating_system(); 7: void print_browser(); 8: 9: int cgiMain() { 10: cgiHeaderContentType("text/html"); 11: fprintf(cgiOut, "<html><head>\n"); 12: fprintf(cgiOut, "<title>C Example</title></head>\n"); 13: fprintf(cgiOut, "<body><h1>C Example</h1>\n"); 14: print_name(); 15: print_secure(); 16: print_operating_system(); 17: print_browser(); 18: fprintf(cgiOut, "</body></html>\n"); ... |
Get Sams Teach Yourself CGI in 24 Hours, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.