CGI (Common Gate Interface)

Doc generation

Two lines at least must be sent to the client:
  1. First line
  2. Second line - a blank line

Example

#include <iostream.h>

main()
{
cout << "Content-type: text/html\n\n"; // 2nd \n is for the 2nd line
cout << "Hello, World!";

return(0);
}
test

Communication btwn Doc and CGI Script

CGI uses environment variables to send your script its parameters:
QUERY_STRING
PATH_INFO
<a href="/cgi/foobar/lang=eng">foobar</a>

Methods to Access Form Inputs

    <FORM ACTION="http://www.csie.ntu.edu.tw/~your_hd/hello.exe" METHOD=GET>
                                     |                      |
                               your ip address         your script
GET
POST

Resources