<!doctype html>
密码:
男 女
描述:
民族: 临沂 北京 河南
char username[256];
char pwd[250];
char desc[256];
char sex[3];
char quyu[256];
if(cgiFormSubmitClicked(“login”) == cgiFormSuccess){
cgiFormString(“username”,username,sizeof(username));
cgiFormString(“pwd”,pwd,sizeof(pwd));
cgiFormString(“sex”,sex,sizeof(sex));
cgiFormString(“desc”,desc,sizeof(desc));
cgiFormString(“quyu”,quyu,sizeof(quyu));
cgiHeaderContentType("text/html;charset=gbk");
//printf(username);
//printf(pwd);
fprintf(cgiOut,"<html><head></head><body>");
fprintf(cgiOut,"用户名:%s,性别:%s",username,quyu);
fprintf(cgiOut,"</body></html>");
return 0;
}
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include"cgic.h"
int cgiMain(){
char model [32]={0};
char fun[32]={0};
if(cgiFromString(“model”,model,sizeof(model))!=cgiFromSuccess){
cgiHeaderContentType(“test/html;charset=gbk”);
printf(“modle参数必传”);
return 0;
}
if(cgiFromString(“fun”,fun,sizeof(fun))!=cgiFromSuccess){
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(“register.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;
}
}
}
<!doctype html>
您的姓名是<TMPL_VAR name="realname"/>,您的年龄是<TMPL_VAR name="age"/>岁
<br/>
<p>列表</p>
<ul>
<TMPL_LOOP name="goods">
<li>商品名称,<TMPL_VAR name ="goodname">,价格,<TMPL_VAR name="price"> <li>
</TMPL_LOOP>
</ul>
#include
int cgiMain(){
cigHeaderContentType(“text/html;charset=gbk”);
//往前台index.html传数据并跳转
TMPL_varlist *varlist=0;
TMPL_loop *loopGoods=0;
varlist=TMPL_add_var(varlist,“realname”,“赵琦”,“age”,“80”,0);
//循环的列表数据
loopGoods=TMPL_add_varlist(loopGoods,TMPL_add_var(0,“goodname”,“裤子”,“price”,“20”,0));
loopGoods=TMPL_add_varlist(loopGoods,TMPL_add_var(0,“goodname”,“褂子”,“price”,“20”,0));
varlist=TMPL_add_loop(varlist,“goods”,loopGoods);
Tmpl_write(“index.html”,0,0,varlist,cgiOut,cgiOut);
Tmpl_fre_varlist(varlist);
return 0;}