首页 > 解决方案 > 检查插入的表“keysystem”值是否已被使用

问题描述

我正在为我的程序进行身份验证,这是我用于简单登录的代码:

$query = $con->query("SELECT * FROM keysystem WHERE keysystem = '$keysystem'");
        $cnt2 = $query->num_rows;


        if($cnt2 > 0)
        {
            echo "GOOD";
        }
        else 
        {
            echo "BAD";
        }

对于 C++,我使用这个:

string DownloadString(string URL) {
    HINTERNET interwebs = InternetOpenA("Mozilla/5.0", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, NULL);
    HINTERNET urlFile;
    string rtn;
    if (interwebs) {
        urlFile = InternetOpenUrlA(interwebs, URL.c_str(), NULL, NULL, NULL, NULL);
        if (urlFile) {
            char buffer[2000];
            DWORD bytesRead;
            do {
                InternetReadFile(urlFile, buffer, 2000, &bytesRead);
                rtn.append(buffer, bytesRead);
                memset(buffer, 0, 2000);
            } while (bytesRead);
            InternetCloseHandle(interwebs);
            InternetCloseHandle(urlFile);
            string p = replaceAll(rtn, "|n", "\r\n");
            return p;
        }
    }
    InternetCloseHandle(interwebs);
    string p = replaceAll(rtn, "|n", "\r\n");
    return p;
}

string login = DownloadString("http://website.com/handler.php?action=login&keysystem=" + license).c_str();

    if (login.find("890") != std::string::npos)
    {
        char buffer[256];
            print::set_text("\n  Successfully logged in!\n\n", Green);

            printf("\n\n");
            Beep(666, 200);
            Sleep(2000);
    }

    else if (login.find("880") != std::string::npos)
    {
        print::set_text("\n  Failed to log in! ", Red);
        Beep(666, 200);
        Sleep(2000);
        exit(0);
    }

它工作正常,但我想检查密钥是否已被某人使用。

标签: phpc++

解决方案


要了解是否使用了您的密钥,您可以添加一个字段,该字段存储是否使用密钥,例如is_used使用true\false值。

然后您的查询变为:

SELECT * FROM keysystem WHERE keysystem = '$keysystem' and is_used = false

当然,不要忘记将字段设置is_usedtrue有人开始使用它的时间。


推荐阅读