#include <stdio.h>
#include <stdlib.h>
#include "sqlite3.h"
#include <string.h>
void main()
{
sqlite3 *db=NULL;
char *Msg = 0 ;
int rc;
int i, n;
char c[100];
char a[2][100]={0};
char b[2][100]={0};
char d[2][100]={0};
char *t,*p,*g;
printf("Content-type: text/html\n\n");
printf("\n");
printf("CGI Output\n");
printf("\n");
if( getenv("CONTENT_LENGTH") )
{
n = atoi( getenv("CONTENT_LENGTH") );
}
else
{
n = 0;
fprintf( stdout, "(NULL)" );
}
for( i=0; i<n; i++)
{
c[i] = getc(stdin);
}
i = 0;
p = strtok(c,"&");
while(p!=NULL&&i<2)
{
strcpy(a[i++],p);
p = strtok(NULL,"&");
}
i=0;
t = strtok(a[0],"=");
while(t!=NULL&&i<2)
{
strcpy(b[i++],t);
t = strtok(NULL,"&");
}
i = 0;
g = strtok(a[1],"=");
while(g!=NULL&&i<2)
{
strcpy(d[i++],g);
g = strtok(NULL,"&");
}
int nrow = 0, ncolumn = 0;
char ** azResult;
char sql[100];
rc = sqlite3_open("z.db",&db);
if(rc)
{
sqlite3_close(db);
exit(1);
}
else
sprintf(sql,"Select * From My where name='%s' and password='%s'",b[1],d[1]);
sqlite3_get_table(db, sql, &azResult, &nrow, &ncolumn, &Msg);
if(azResult[1]==NULL)
{
printf("Login faile!");
}
else
{
printf("Login success!");
}
sqlite3_free_table(azResult);
sqlite3_close(db);
printf("
\n");
printf("\n");
exit(0);
}
|