Linux环境下使用C/C++编写CGI之安装cgicc模块

****直接进入主题****

  • Step-One:下载cgicc
    传送cgicc下载地址

Step-Two:编译安装

$ tar xzf cgicc-X.X.X.tar.gz(用最新版本)
$ cd cgicc-X.X.X
$ ./configure --prefix=/usr
$ make
$ sudo make install

至此已经安装完成~~~


Sameple

  • file form.html

名:
姓:

  • cpp_get.cpp
#include 
#include   
#include   
#include   
#include  
#include  
#include  
#include  
#include   
using namespace std;
using namespace cgicc;
int main (){
   Cgicc formData;
   cout << "Content-type:text/html\r\n\r\n";
   cout << "\n";
   cout << "\n";
   cout << "\n";
   cout << "使用 GET 和 POST 方法\n";
   cout << "\n";
   cout << "\n";

   form_iterator fi = formData.getElement("first_name");  
   if( !fi->isEmpty() && fi != (*formData).end()) {  
      cout << "名:" << **fi << endl;  
   }else{
      cout << "No text entered for first name" << endl;  
   }
   cout << "
\n"; fi = formData.getElement("last_name"); if( !fi->isEmpty() &&fi != (*formData).end()) { cout << "姓:" << **fi << endl; }else{ cout << "No text entered for last name" << endl; } cout << "
\n"; cout << "\n"; cout << "\n"; return 0; }

  • 编译
$ g++ -o cpp_get.cgi cpp_get.cpp -lcgicc

Linux环境下使用C/C++编写CGI之安装cgicc模块_第1张图片
Paste_Image.png

**** 价值源于技术,贡献源于分享****

你可能感兴趣的:(Linux环境下使用C/C++编写CGI之安装cgicc模块)