By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,526 Members | 1,888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,526 IT Pros & Developers. It's quick & easy.

display a html file

100+
P: 254
I have a html file contains a form asking user to select a choice and press enter to pass the data to server.

In server there, i have a cgi script(C language) that accepts the input from browser and then output a html page to browser.

The browser should open the page, but it didn't, instead, it prompt me to save the file(.cgi file i requested in form method)....

how that happens?
i want to display the html file that the script output to browser, not to save that file.

here is my script:
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. extern void  cgiGetInput();
  4. extern char *cgiGetValue(char *name);
  5. extern char *cgiGetName();
  6. extern void cgiReset();
  7. extern char *cgiGetKeyword();
  8.  
  9. /** Turn debuggine on or off **/
  10. int Debug = 0;
  11.  
  12. int main(int argc, char *argv[], char *env[]) {
  13.  
  14.     if(Debug){
  15.         fprintf(stderr, "Start of script\n");
  16.     }
  17.     cgiGetInput();
  18.  
  19.     /*
  20.     **    print out Version Choice Form page to browser
  21.     */
  22.  
  23.     // output the content type
  24.     printf("Content-Type: text/html\r\n");
  25.  
  26.     printf("\r\n");
  27.  
  28.     printf("<html><head><title>Version Choice Form</title></head>\n");
  29.     printf("<body>\n");
  30.  
  31.     printf("<p class=\"title\">Versoin Choice Form!!</p>");
  32.  
  33.     printf("The choice you made is %s", cgiGetValue("sound"));
  34.  
  35.     printf(
  36.         "<form method=\"POST\">"
  37.         "<input type=\"radio\" name=\"version\" value=\"original\" checked /> Original Version\n"
  38.         "<input type=\"radio\" name=\"version\" value=\"dynamic\" /> dynamically-created \"echo\" version\n\n"
  39.         "<input type=\"submit\" name=\"retrieve\" value=\"Retrieve Sound\" />"
  40.         "</form>"
  41.         );
  42.  
  43.     printf("</body></html>");
  44.     return 0;
  45. }
  46.  
html file
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC
  2.           "-//W3C//DTD HTML 4.01 Transitional//EN"
  3.           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" lang="EN">
  5. <head>
  6. <title>Select a sound</title>
  7. </head>
  8.  
  9. <body>
  10. <h1>Forms Page 1</h1>
  11. This page is an example of a forms page with a submit button. This is the
  12. first of 2 forms pages. Both pages call the same script. How does the
  13. script know which page has been used?
  14. <p />
  15. <form action="assign2.cgi" method="get">
  16.  
  17. <p />
  18. Select a sound you want to hear :<br />
  19. Train sound<input type="RADIO" name="sound" value="train" checked />
  20. Yes sound <input type="radio" name="sound" value="yes" />
  21.  
  22. <p />
  23. <input type="RESET" value="Reset" />
  24. <input type="SUBMIT" value="Next" name="form1" />
  25. </form>
  26. </body> </html>
  27.  
it should display that dynamic html page, how come browser ask me to save that file?
ps: i use Mozilla Firefox browser.
Jan 16 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 1,892
Is this an HTML question? Looks more like a C question I will copy this thread to that forum.
Jan 16 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.