What is a Query String?A query string is a data container appended to your url address. Query strings provide a web surfer a way of passing information specific to the user to a particular web address. The host computer can parse the query string and send a customized result back to the surfer. Most basic example of a query string is the google search engine. Google listens for search requests through the query string. In google's case they use 'q' as the identifier for their search string. If 'q' is full, google knows the user is requesting a web search for the value of 'q'. So if 'q' was sent to google with the value of "frog" Google knows to send results for frog like so. http://www.google.com/search?q=frog. Thanks to the query string you can send yourself to google or any other site by pre-filling the desired variable.
Query strings are known as environmental variables to the host computer. As environmental variables they are universal to all host applications. You can pass environmental variables in two methods, GET and POST. The above example uses the GET method. You know this because GET appends the arguments to the end of a url address. Everything after the question mark is the query string. POST works the same way as GET except for the way they are transmitted. POST appends to variables and sends them after the url address is a second packet. POST is generally used for longer strings of data, Neither GET nor POST provides any security benefits, POST looks better in a url because the url window address is much shorter. You may use GET and POST together in combination or seperately. So how do i parse the query string? The answer really depends on the language you are using. PHP, Perl, javascript all require different routines to access and parse the same query string. Since it is an environmental variable, the query string's official name is "QUERY_STRING". But certain language will rename this before porting it into your favorite scripting language. |