明辉站/网站教程/内容

CGI图文说明教程(7)解码数据发送给CGI脚本之3

网站教程2023-12-24 阅读
[摘要]解码数据发送给CGI脚本下面举个例字,如果QUERY_STRING包含以下内容:tag=one&name=mike&action=%2B10%25&tag=two&log=~mas/log&tag=three 那么以下的程序将被编译和运行: enum boo...
解码数据发送给CGI脚本

下面举个例字,如果QUERY_STRING包含以下内容:

tag=one&name=mike&action=%2B10%25&tag=two&log=~mas/log&tag=three

那么以下的程序将被编译和运行:

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";

}

}

结果它的输出为:

name = mike

action= +10%

log = /usr/staff/mas/log

tag (1) = one

tag (2) = two

tag (3) = three

tag (4) =

……

相关阅读