下面的 C++ 程序会生成 cpp_checkbox.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; boolmaths_flag, physics_flag; cout << "Content-type:text/html\r\n\r\n"; cout << "\n"; cout << "\n"; cout << "向 CGI 程序传递复选框数据\n"; cout << "\n"; cout << "\n"; maths_flag = formData.queryCheckbox("maths"); if(maths_flag){ cout << "Maths Flag: ON " << endl; }else{ cout << "Maths Flag: OFF " << endl; } cout << "
\n"; physics_flag = formData.queryCheckbox("physics"); if(physics_flag){ cout << "Physics Flag: ON " << endl; }else{ cout << "Physics Flag: OFF " << endl; } cout << "
\n"; cout << "\n"; cout << "\n"; return0;}