CGI圖文說明教程(7)解碼數(shù)據(jù)發(fā)送給CGI腳本之3
發(fā)表時(shí)間:2023-12-26 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]解碼數(shù)據(jù)發(fā)送給CGI腳本下面舉個(gè)例字,如果QUERY_STRING包含以下內(nèi)容:tag=one&name=mike&action=%2B10%25&tag=two&log=~mas/log&tag=three 那么以下的程序?qū)⒈痪幾g和運(yùn)行: enum boo...
解碼數(shù)據(jù)發(fā)送給CGI腳本
下面舉個(gè)例字,如果QUERY_STRING包含以下內(nèi)容:
tag=one&name=mike&action=%2B10%25&tag=two&log=~mas/log&tag=three
那么以下的程序?qū)⒈痪幾g和運(yùn)行:
enum bool { false, true };
#include
#include
#include "parse.h"
#include "parse.cpp"
void main()
{
char *query_str = getenv("QUERY_STRING");
Parse list( query_str );
cout << "name = " << list.get_item_n( "name" ) << "\n";
cout << "action= " << list.get_item_n( "action" ) << "\n";
cout << "log = " << list.get_item_n( "log", 1, true ) << "\n";
for ( int i=1; i<=4; i++ )
{
cout << "tag (" << i << ") = ";
cout << list.get_item_n( "tag" , i ) << "\n";
}
}
結(jié)果它的輸出為:
name = mike
action= +10%
log = /usr/staff/mas/log
tag (1) = one
tag (2) = two
tag (3) = three
tag (4) =