diff --git a/cgi-bin/sqlite_cgi_base.c b/cgi-bin/sqlite_cgi_base.c index ad4c81a..bbb8793 100644 --- a/cgi-bin/sqlite_cgi_base.c +++ b/cgi-bin/sqlite_cgi_base.c @@ -4,6 +4,7 @@ #include // cJSON *result_json; // 用于存储查询结果 +char login_user_name[32] = ""; // sqlite3的回调函数 // sqlite 每查到一条记录,就调用一次这个回调 @@ -60,6 +61,7 @@ int main(int argc, char const *argv[]) // 拿到用户名和密码 char *username_from_frontend = user->valuestring; char *password_from_frontend = password->valuestring; + sprintf(login_user_name, "%s", username_from_frontend); printf("username is %s, pwd is %s\n", username_from_frontend, password_from_frontend); @@ -108,8 +110,10 @@ int sql_search_callback(void *NotUsed, cJSON_AddStringToObject(result_json, "msg", "用户名或密码错误"); } else + { cJSON_AddNumberToObject(result_json, "code", 0); - + cJSON_AddStringToObject(result_json, "login_user_name", login_user_name); + } char *result_json_string = cJSON_Print(result_json); // 输出 JSON 结果 diff --git a/html/index.html b/html/index.html new file mode 100644 index 0000000..1bbf16d --- /dev/null +++ b/html/index.html @@ -0,0 +1,95 @@ + + + + + + + + 首页 + + + + + +
+ +
+ + + +
+
+ +
+ +
+ + + + + + + \ No newline at end of file diff --git a/html/login.html b/html/login.html index 817a10b..35c244c 100644 --- a/html/login.html +++ b/html/login.html @@ -162,7 +162,7 @@ console.log(data); if (data.code == 0) { window.localStorage.setItem("login_user", JSON.stringify(data)); - open("./zhuti.html", "_self"); + open("./index.html", "_self"); } else { alert(data.msg); }