CGI programming for goahead in Linux

Source: Internet
Author: User

CGIProgramThe executable files are stored in the goahead/web/cgi-bin/directory, which can be directly compiled and generated using gcc. The webpage file is stored in the goahead/web/directory. The source file is as follows:

// Test. c

# Include <stdio. h>
# Include <stdlib. h>
Int main (void)
{
Char * data;
Long M, N;
Printf ("Content-Type: text/html/n ");
Printf ("<title> multiplication result </title> ");
Printf ("Data = getenv ("QUERY_STRING ");
If (Data = NULL)
Printf ("<p> error! Data is not input or there is a problem with data transmission ");
Else if (sscanf (data, "m = % LD & n = % lD", & M, & N )! = 2)
Printf ("<p> error! The input data is invalid. The number must be entered in the form. ");
Else
Printf ("<p> % LD and % ld: % lD. ", M, n, m * n );
Return 0;
}

 

// Test.html

<Form action = "/cgi-bin/test">
<Input name = "M" size = "5">
<Input name = "N" size = "5"> <br>
<Input type = "Submit" value = "OK">
</Form>

 

After compilation, run goaheadand execute the CGI program in ie‑test.html!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.