#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mysql.h"
#define MYSQL_HOST "localhost" // database server name
#define MYSQL_DB "test" // database name
#define MYSQL_USERID "testuser" // database user id
#define MYSQL_PASSWD "testpass" // userid password
#define MYSQL_TABLE "pets" // table name
#define PROGRAM_HEADER "<H1>MySQL C-API Example Query Results</H1>\n"
// This is not the best or safest way to process field forms in C since
// sscanf is unsage. It is used here only to simplify the example
void GetFormField(char *value) {
char *data;
data = "name=joe";
/* data = getenv("QUERY_STRING"); */
if(data == NULL) {
strcpy(value,"");
return;
}
// make sure data does not exceed maximum length
if (strlen(data) > 20) {
strcpy(value,"");
return;
}
/* input is read from data, nu of matches returned */
if (sscanf(data,"name=%s",value) != 1) {
strcpy(value,"");
}
}
int main() {
char * vale;
GetFormField(vale);
printf("%s\n",vale);
}
return to top