Unable to send text from html file to c file -


i'm trying write basic html file , cgi script. html file have 1 text box , button. button send contents of text box cgi file (without content of text box showing in url) print out contents of text box. instead of happening, cgi file prints out '-|' regardless of put in text box.

here .html file:

<html>  <head>   <title>template webpage</title> </head>  <body bgcolor="white" text="black">    <form action="http://cgi.cs.mcgill.ca/~eross12/cgi-bin/results.cgi" method="gets">     <div><label>input: <input name="data" size="5"></label></div>     <div><input type="submit" value="send!"></div>   </form>  </body> </html> 

and here c file supposed receiving text html file:

#include <stdio.h> #include <stdlib.h> int main(void) {   char *data;   char *input;   printf("%s%c%c\n","content-type:text/html;charset=iso-8859-1",13,10);   printf("<title>received data</title>\n");   printf("<h3>received data</h3>\n");   data = getenv("query_string");   if(data == null)     printf("<p>error! error in passing data form script.");   else   {     fgets(input,256,stdin);    printf("<p>the input is: \"%s\"",input);   }  return 0; } 

from i've read online believe if want use fgets 'method' in form should post instead of gets if make change internal server error when click on button. if tell me changes need make extremely grateful! alternatively, if show me basic .html file , basic c script i'm describing wonderful! unfortunately can't use javascript or php or various other tools i've seen people recommend in response other questions on stackoverflow.

p.s. if want see .html file in action, click here , if want see method set post instead of gets click here.

the main problem code input uninitialized.

that's why getting internal server error when using post.

just replace char *input; char *input = (char*)malloc(1000); , should work.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -