Monday, 15 September 2014

cgi - Trouble Storing arguments from Query string in C++ -


I am trying to parse a query string and store each argument in a specific string (like an APR) , But I'm figuring out it's a 'difficult time' Now I'm capable of displaying every argument from URL like ... ... assign09.cgi? Apr = 2 & amp; Word = 4 & amp; The amount = 7 I am able to get '2' '4' and '7', but whenever I try to specify a value for a string, I get an internal server error. Besides, I think I'm running through the string because I'm a '?' At the end of my output for my loop

My main question is: Do I want to have a good way to parse query string?

  #include & lt; Iostream & gt; #include & lt; String & gt; # Include & lt; Cstdlib & gt; using namespace std; Int main () {cout & lt; & Lt; "Content types: text / html \ r \ n \ r \ n"; String s = getenv ("QUERY_STRING"); String apr; String Lontarm; String loan amount; String monthly payments; // apr, lonatarm, and monthly payment string aggregates [3]; Cout & lt; & Lt; "& Lt; html & gt; \ n"; Cout & lt; & Lt; "& Lt; top & gt; \ n"; Cout & lt; & Lt; "& Gt; Title & gt; Hello World - First CGI Program & lt; / title & gt; \ n"; Cout & lt; & Lt; "& Lt; / head & gt; \ n"; Cout & lt; & Lt; "From & lt; body & gt; \ n"; Cout & lt; & Lt; "& Lt; h1 & gt; monthly mortgage & lt; / h1 & gt; \ n"; Cout & lt; & Lt; "& Lt; p & gt;" & Lt; & Lt; S & lt; & Lt; "& Lt; / p & gt; \ n"; For (int i = 0; i & lt; s.length (); i ++) {if (s [i] == '=') {for (int k = i + 1; s [k] ! = '& Amp;'; K ++) {cout & lt; & Lt; "& Lt; p & gt;" & Lt; & Lt; S [k] & lt; & Lt; "& Lt; / p & gt;"; }}} Cout & lt; & Lt; "& Lt; / body & gt; \ n"; Cout & lt; & Lt; "& Lt; / html> \ n"; Return 0; }  


No comments:

Post a Comment