最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

inno setup - Innosetup how to validate key using database+php - Stack Overflow

programmeradmin7浏览0评论

I'm trying to get the key that is inside the sql list on a local server to learn but it's returning this error Exception:Winhttprequest

I know there are several similar topics, but so far I haven't found anything with a database.

Pascal Script

function ValidateActivationKey(key: string): Boolean;
var
  WinHttpReq: Variant;
begin
  Result := False;

  try
    WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
    WinHttpReq.Open('GET', 'https://localhost/PHP2/verify_key.php?key=' + key, False);
    WinHttpReq.Send();

    if WinHttpReq.Status = 'Validated' then
    begin
      MsgBox('Valid key! Starting installation.', mbInformation, MB_OK);
      Result := True;
    end
    else
    begin
      MsgBox('Invalid or already used key.', mbError, MB_OK);
    end;

  except
    MsgBox('Error connecting to server.', mbError, MB_OK);
  end;
end;

function InitializeSetup(): Boolean;
var
  key: string;
begin
    Result := ValidateActivationKey(key);
  end;

Php

$key = $_GET['key'] ?? '';

if ($key == '') {
    die("ERRO: Key not provided.");
}


$sql = "SELECT * FROM keys WHERE key = '$key' AND activated = 0";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    $conn->query("UPDATE keys SET activated = 1 WHERE key = '$key'");
    echo "VALID";
} else {
    echo "INVALID";
}

$conn->close();
?>

SQL

If you can give me a hint or where the error might be, I would greatly appreciate it.

发布评论

评论列表(0)

  1. 暂无评论