用C/C++写CGI程序
用C/C++写CGI程序
使用CGIC库的简要:
库的函数说明: http://www.boutell.com/cgic/#cgiFormStringNoNewlines
1. 打印CGI标准输出头部:
cgiHeaderContentType("text/plain");
或者:
fprintf( stdout, "Content-type:text/plain\n\n");红色部分不能写出“Contenttype”,否则浏览器显示网页会不正常。
2. 处理Request Method:
//deal with "GET"/"POST" method
if (strncmp(cgiRequestMethod, "post",4) == 0)
{
handlePostRequest();
}
else //"GET"
{
handleGetRequest();
}
3. 获取QueryString中的各个字段值:
cgiFormStringNoNewlines("query1", cmdstr, sizeof(cmdstr));
if (strcmp(cmdStr, "ip_address") == 0)
{
...
}
else
...
4. CGI输出:fprintf(cgiOut, "%s\n", cgi_Output);
以下是一些细节:
一、 C/C++编写CGI程序之form处理
1. GET
2. POST
3. 结束
我们有一张web
test.html
<html>
<head>
<title>form test</title>
</head>
<body>
<form method="get" name="test-get" action="./cgi-bin/test-get.cgi">
<input name="name"><input name="pswd"><input type=submit value="get">
</form>
<br><br>
<form method="post" name="test-post" action="./cgi-bin/t
相关文档:
C/C++是不检查数组下标是否越界的。
不检查下标是否越界可以有效提高程序运行的效率,因为如果你检查,那么编译器必须在生成的目标代码中加入额外的代码用于程序运行时检测下标是否越界,这就会导致程序的运行速度下降,所以为了程序的运行效率,C/C++才不检查下标是否越界。
  ......
C/VC目录操作
星尘 发表于 2006-10-11 15:54:00
0
推荐
一、目录操作函数介绍
在VC++的“direct.h”中定义了以下4个函数:
int chdir(const char *); //change directory
char * getcwd(char *, int); //get current working directory
int mkdir(const cha ......
3.内功题
试题1:分别给出BOOL,int,float,指针变量 与“零值”比较的 if 语句(假设变量名为var)
解答:
BOOL型变量:if(!var)
int型变量: if(var==0)
float型变量:
const float EPSINON = 0.00001;
if ((x >= - EPSINON) && (x <= EPSI ......
首先安装必需的开发
包
sudo apt-get install gcc g++ libgcc1 libg++ make gdb
安装MYSQL的C语言开发包
sudo apt-get install libmysql++-dev libmysql++2c2a libmysqlclient15-dev libmysqlclient15off
把lib文件拷贝到公用
sudo cp /usr/lib/mysql/* /usr/lib/
建立一个新文件test.cpp
vim test.cpp
输入内容
......