cgi - Trouble Storing arguments from Query string in C++ -
i'm trying parse query string , store each argument in specific string (such apr), i'm having hard time figuring out. right able display each argument url like: ...assign09.cgi?apr=2&term=4&amount=7. able '2' '4' , '7' out of this, whenever try assign value string, internal server error. also, think running off of string because '?' @ end of output loop.
my main question is: way parse query string want?
#include <iostream> #include <string> #include <cstdlib> using namespace std; int main () { cout << "content-type:text/html\r\n\r\n"; string s = getenv("query_string"); string apr; string loanterm; string loanamount; string monthlypayment; // apr, loanterm, , monthlypayment string args[3]; cout << "<html>\n"; cout << "<head>\n"; cout << "<title>hello world - first cgi program</title>\n"; cout << "</head>\n"; cout << "<body>\n"; cout << "<h1>monthly mortgage</h1>\n"; cout << "<p>" << s << "</p>\n"; for(int = 0; < s.length(); i++) { if(s[i] == '=') { for(int k = + 1; s[k] != '&'; k++) { cout << "<p>" << s[k] << "</p>"; } } } cout << "</body>\n"; cout << "</html>\n"; return 0; }
Comments
Post a Comment