日期:2014-05-16 浏览次数:20474 次
一 平台介绍
硬件:s3c2410开发板(我用的是友善之臂的)、pc机。
软件:boa服务器、sqlite数据库(需要把服务器和数据库都配置好)
二程序源代码
源代码如下:

(1)index.html
<html><meta http-equiv="Content-Type" content="text/html; charset=gbk"/> 
<head><title>用户登陆验证</title></head> 
<body> 
<form name="form1" action="/login/index.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>
(2)index.c(该文件可以生成index.cgi)
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include "sqlite3.h" 
char* getcgidata(FILE* fp, char* requestmethod); 
int main() 
{ 
             char *input; 
             char *req_method; 
             char namein[12]; 
             char pass[12]; 
             char passtemp[12]; 
             int i = 0; 
             int j = 0; 
            
             printf("Content-type: text/html\n\n"); 
        
             req_method = getenv("REQUEST_METHOD"); 
             input = getcgidata(stdin, req_method); 
             // 我们获取的input字符串可能像如下的形式 
             // Username="admin"&Password="aaaaa" 
             // 其中"Username="和"&Password="都是固定的 
             //