[英]PHP Insert value if column is null
我正在使用一個加載程序,一旦用戶正確身份驗證,該加載程序將加載文件,但是在我要啟動文件流之前,我想檢查其HWID以進行檢查,以使其與數據庫上的HWID匹配,並且我設法做到了我這樣做是這樣的:
function validate_Hwid(){
global $db, $encryptionEngine;
if (isset($_GET['username']) && isset($_GET['hwid'])) {
$username = $encryptionEngine->init($_GET['username'],"decrypt");
$hwid = $encryptionEngine->init($_GET['hwid'],"decrypt");
$query = $db->simple_select("users", "*", "LOWER(username)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));
$user = $db->fetch_array($query);
if ($hwid == $user['hwid']) {
return 1;
} else {
return 0;
}
} else {
return 0;
}
}
但是我有一個問題,如果用戶在DB上的HWID為空之前從未登錄過,該如何更改,如果用戶上的HWID為空,那么我將插入我提供的字符串嗎?
if ($user['hwid'] == null)
{
// insert and call func again
} elseif ($hwid == $user['hwid']) {
return 1;
} else {
return 0;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.