php - 检查插入的表“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);
}
它工作正常,但我想检查密钥是否已被某人使用。
解决方案
要了解是否使用了您的密钥,您可以添加一个字段,该字段存储是否使用密钥,例如is_used
使用true
\false
值。
然后您的查询变为:
SELECT * FROM keysystem WHERE keysystem = '$keysystem' and is_used = false
当然,不要忘记将字段设置is_used
为true
有人开始使用它的时间。
推荐阅读
- dart - Stream 何时开始向侦听器发布值?
- php - PHP/MYSQL 替换字典数组中键的文本
- docker - 为什么 docker run 命令无法识别指定的环境变量?
- c++ - 继承的方法不会改变变量值
- node.js - 在 Node 中,为什么“需要”赋值有时需要大括号?
- c# - 有没有办法在 Visual Studio 中将 Outlook 项目保存为 pdf?
- libgdx - Libgdx GestureDirector pan 在处理多个手指时表现异常
- angular - 如何从 Azure 门户应用程序设置添加自定义声明
- c# - 如何为 Forge API 提供签名的 url 以创建 revit 文件
- python-2.7 - 为什么scrapy raise 响应内容不是文本?