Page 1 of 1

CGI Executable

PostPosted: 22. February 2008 12:28
by MyOverflow
How do I get XAMPP to use an executable file as a CGI script? I've written the executable in C, here's the C source code:
Code: Select all
#include <stdio.h>
#include <stdlib.h>

int main() {
   char *buf;
   printf("%s%c%c\n", "Content-type=text/html;charset:iso-8859-1",13,10);
   printf("<html>\n<head>\n<title>CGI EXE</title>\n</head>\n<body>\n<p>");
   printf("<h1>Your Form Results:</h1>");

   buf = getenv("QUERY_STRING");

   if(buf == NULL)
      return -1;

   printf("My ");
   int i = 0;
   while(buf[i] != '=')
      printf("%c", buf[i++]);
   printf(" is: ");
   i++;
   while(buf[i] != '&')
      printf("%c", buf[i++]);
   printf("\n\nMy ");
   i++;
   while(buf[i] != '=')
      printf("%c", buf[i++]);
   printf(" is: ");
   i++;
   while(buf[i] != '&')
      printf("%c", buf[i++]);

   printf("\n</body>\n\n</html>");

   return 0;
}

and here's the form I'm using:
Code: Select all
<form action="result.exe">
<input type="text" name="name" /><br />
<input type="text" name="nickname" /><br />
<input type="submit" value="Click!" />
</form>


How do I get XAMPP to treat result.exe as a CGI file?

PostPosted: 22. February 2008 13:58
by Wiedmann
e.g: Put this exe file in the cgi-bin directory.