第九页:
左:
右:
char username[238];
char pwd[50];
char desc[256];
char sex[3];
char quyu[156];
if(cgiFromSubmitClicked("login") == cgiFormSuccess)
{
cgiFormString("username",username , sizeof(username));
cgiFormString("pwd",pwd , sizeof(pwd));
cgiFormString("desc",desc , sizeof(desc));
cgiFormString("sex",sex , sizeof(sex));
cgiFormString("quyu",quyu , sizeof(quyu));
cgiHeaderContentType("text/html;charset=gbk");
//printf("username");
//printf("pwd");
fprintf(cgiOut, "
");fprintf(cgiOut, "");
return 0;
}
10页:
左:
#include
#include
#include
#include "cgic.h"
int cgiMain()
{
char model[30] = { 0 };//哪个模块进来的
char fun[32] = { 0 };
//project01.cgi?model=user&fun=login
//project01.cgi?model=user&fun=register
if (cgiFormString("model", model, sizeof(model) != cgiFormSuccess)
{
cgiHeaderContentType("text/html;charset=gbk");
printf("fun参数必传");
}
return 0;
}
右:
if (strcmp(model, "user") == 0)
{
if (strcmp(fun, "toLogin") == 0)
{
cgiHeaderLocation("login.html");
}
else if (strcmp(fun, "toRegister") == 0)
{
cgiHeaderLocation("regitser.html");
}
else if (strcmp(fun, "login") == 0)
{
char username[256];
char pwd[250];
cgiFormString("username", username, sizeof(username);
cgiFormString("pwd", pwd, sizeof(pwd);
//查询数据库对比用户名密码的;
if (strcmp(username, "zq") == 0 && strcmp(pwd, "123") == 0)
{
cgiHeaderContentType("text/html;charset=gbk");
printf("登陆成功");
return 0;
}
else
{
cgiHeaderContentType("text/html;charset=gbk");
printf("用户名或密码错误");
return 0;
}
}
}
第11页:
无标题文档
您的姓名是 , 您的年龄是 岁
列表
第12页:
#include
#include
#include
#include "cgic.h"
int cgiMain()
{
cgiHeaderContentType("text/html;charset=gbk");
//往前台index.html传数据并转跳
TMPL_varlist * varlist = 0;
TMPL_loop *loopGoods = 0;
varlist = TMPL_add_var(varlist, "realname", "赵琦", "price", "20", 0);
//循环的列表数据
loopGoods = TMPL_add_var(loopGoods, TMPL_add_var(0, "goodname", "裤子", "price", "20", 0));
loopGoods = TMPL_add_var(loopGoods, TMPL_add_var(0, "goodname", "褂子", "price", "10", 0));
varlist = TMPL_add_loop(varlist, "goods", loopGoods);
TMPL_write("index.html", 0, 0, varlist, cgiOut, cgiOut);
TMPL_free_varlist(varlist);
return 0;
}