Form Query String to .EXE (C++) Cgi App

 
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI
View previous topic :: View next topic  
Author Message
DarkSlasher117
-


Joined: 07 Apr 2003
Posts: 3

PostPosted: Sun Jul 27, 2003 5:37 am    Post subject: Form Query String to .EXE (C++) Cgi App Reply with quote

Perhaps this is a stupid question (just to be on the safe side):

I'm in the process of writing a C++ CGI app. I have no problems getting it to run; however, I am having difficulties when submitting form (html) data to it.

Code:

void main(int ArgType, char* Args[])
{
   string Query;
   cout << "Content-type: text/html\n\n";
   for(int i=0;i<ArgType;i++)
   {
      Query+=Args[i];
      if(i!=ArgType-1) Query+=" ";
   }
   cout << Query << "<br>" << endl;
   cout << "blablabla" << endl;
}


When I run the program (http://localhost:8081/cgi-win/program.exe?) - it works fine. When I enter parameters like: program.exe?this is a test - it also works fine. However - when I start puting equal signs (=) into the query - I no longer see the arguments. Thus:
Running with "program.exe?hi this is a test" results in "E:\...program.exe hi this is a test"
Running with "program.exe?this=test", however, results in "E:\...program.exe" (notice how the this=test is not printed out).

I want to know how to get it so that I see the query regardless of whether it has an equal sign. Otherwise, form queries in the format of item1=bla&item2=bla2...... won't be processed by the executable.

I hope I'm just overlooking something very obvious.
Back to top View user's profile Send private message
DarkSlasher117
-


Joined: 07 Apr 2003
Posts: 3

PostPosted: Sun Jul 27, 2003 5:39 am    Post subject: Multiple Queries Reply with quote

Just to make it clear...if I run the app with a query like "program.exe?this is a test" - the result is ArgType being 5. Args[0]=thefile, Args[1]=this, Args[2]=is....Args[4]=test.
Back to top View user's profile Send private message
DarkSlasher117
-


Joined: 07 Apr 2003
Posts: 3

PostPosted: Sun Jul 27, 2003 5:52 am    Post subject: Fixed it myself Reply with quote

Ok...I figured it out (although it isn't what I originally wanted to do...):

Changed form method from GET to POST.
Removed Enviromental-Variable inputs and instead used a CIN>>QUERY;

But now I can't write my own queries in the address bar :(

Ah well.
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sun Jul 27, 2003 6:21 pm    Post subject: Re: Fixed it myself Reply with quote

We recommend reading the CGI specification (the URL is in the CGI chapter in the server's documentation).

What follows the ? mark can be found in the environment variable QUERY_STRING.

If you are going to use CGI from C or C++, there are many libraries that will do the low-level job for you. It is better to use them if you doesn't want to reinvent the wheel (our preferred CGI library is CGIC from http://www.boutell.com/cgic/ ).
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group