Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CGI header declaration format: Context-Type and Content-

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

In POST mode, Context-Type and Content-Type are very different.

Context-Type: printf("Context-Type:text/html;charset= UTF-8\n\n"); ----The page does not recognize html format language, all output on the page as is. If there is no html format language in CGI, just do other processing, no impact on the results.

Content-Type: printf("Content-Type:text/html;charset= UTF-8\n\n"); ---HTML language recognized by web pages

The code is as follows:

#include

#include

#include

#include "sqlite3.h"

#define SQL_SELECT "select name, devid, devname from userinfo where username='sume';"

struct __userinfo{

char name[20];

char dearname[20];

char telephone[12];

char address[200];

char devid[26];

char devname[20];

}user;

int main(void)

{

//Declares web page format

//printf("Content-Type:text/html;charset=UTF-8\n\n");

printf("Context-Type:text/html;charset=UTF-8\n\n");

//Get web page response

int len = atoi(getenv("CONTENT_LENGTH"));

char buf[100]={0};

int ret = fread(buf, 1, 256, stdin);

//Open SQL

sqlite3 *ppdb = NULL;

ret = sqlite3_open("/mnt/hgfs/Share/program3/userinformation.db", &ppdb);

if(ret != SQLITE_OK)

{

printf("

SQLITE OPEN FAIL\n\n");

return -1;

}

char *err = NULL;

char **result = NULL;

//Display the content of my device information

int row = 0, col = 0;

result = NULL;

ret = sqlite3_get_table(ppdb, SQL_SELECT, &result, &row, &col, &err);

if(ret != SQLITE_OK)

{

printf("SEE FAIL : %s\n", err);

sqlite3_close(ppdb);

printf("\n\n");

printf("\n\n");

printf("Server busy, please wait\n\n");

printf("\n\n");

printf("\n\n");

printf("\n\n");

return -1;

}

int i=0, j=0;

for(i=1; i

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report