下面的 C++ 程序会生成 cpp_dropdown.cgi 脚本,用于处理 Web 浏览器通过下拉框给出的输入。
实例
#include<iostream>#include<vector> #include<string> #include<stdio.h> #include<stdlib.h>#include<cgicc/CgiDefs.h>#include<cgicc/Cgicc.h>#include<cgicc/HTTPHTMLHeader.h>#include<cgicc/HTMLClasses.h>usingnamespacestd;usingnamespacecgicc; intmain(){ CgiccformData; cout << "Content-type:text/html\r\n\r\n"; cout << "\n"; cout << "\n"; cout << "向 CGI 程序传递下拉框数据\n"; cout << "\n"; cout << "\n"; form_iteratorfi = formData.getElement("dropdown"); if( !fi->isEmpty() && fi != (*formData).end()){ cout << "Value Selected: " << **fi << endl; } cout << "
\n"; cout << "\n"; cout << "\n"; return0;}