View previous topic :: View next topic |
Author |
Message |
DarkSlasher117 -
Joined: 07 Apr 2003 Posts: 3
|
Posted: Sun Jul 27, 2003 5:37 am Post subject: Form Query String to .EXE (C++) Cgi App |
|
|
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 |
|
|
DarkSlasher117 -
Joined: 07 Apr 2003 Posts: 3
|
Posted: Sun Jul 27, 2003 5:39 am Post subject: Multiple Queries |
|
|
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 |
|
|
DarkSlasher117 -
Joined: 07 Apr 2003 Posts: 3
|
Posted: Sun Jul 27, 2003 5:52 am Post subject: Fixed it myself |
|
|
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 |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Sun Jul 27, 2003 6:21 pm Post subject: Re: Fixed it myself |
|
|
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 |
|
|
|