From c2b047a667c721b0451ee53eedd7f9e7ed261f4b Mon Sep 17 00:00:00 2001 From: flykhan Date: Fri, 27 Oct 2023 10:51:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BB=E9=A1=B5=E4=B8=BAin?= =?UTF-8?q?dex.html;=20localstorage=E5=AD=98=E5=82=A8=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=9A=84=E7=94=A8=E6=88=B7=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cgi-bin/sqlite_cgi_base.c | 6 ++- html/index.html | 95 +++++++++++++++++++++++++++++++++++++++ html/login.html | 2 +- 3 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 html/index.html 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); }