标签:blog class code tar ext get
aries@ubuntu:/usr/lib/cgi-bin$ cat login.c
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
int main(){
int i,len=0;
char poststr[100];
char m[10],n[10];
char *req_method;
printf("Content-type:text/html\n\n");
printf("<meta charset=\"utf-8\">");
printf("<title>检测页面</title>");
printf("<h1>将post过来的和数据库中的信息进行比对即可</h11>");
req_method = getenv("REQUEST_METHOD");
if (!strcmp(req_method, "POST"))
len=atoi(getenv("CONTENT_LENGTH"));
printf("传过来的字符数: %d \n",len);
fgets(poststr,len+1,stdin);
printf("显示post过来的数据:<br /><br />");
printf("%s\n",&poststr);
return 0;
}
aries@ubuntu:/usr/lib/cgi-bin$ ls
login.c login.cgi
aries@ubuntu:/var/www$ cat login.html
<html>
<head><title>用户登陆验证</title></head>
<body>
<form name="form1" action="/cgi-bin/output.cgi" method="POST">
<table align="center">
<tr><td align="center" colspan="2"></td></tr>
<tr>
<td align="right">用户名</td>
<td><input type="text" name="Username"></td>
</tr>
<tr>
<td align="right">密 码</td>
<td><input type="password" name="Password"></td>
</tr>
<tr>
<td><input type="submit" value="登 录"></td>
<td><input type="reset" value="取 消"></td>
</tr>
</table>
</form>
</body>
</html>
获取成功!
ubuntu 下CGI c语言 获取form表单的数据,布布扣,bubuko.com
标签:blog class code tar ext get
原文地址:http://blog.csdn.net/u010236550/article/details/25135489