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

I'm trying to get the key that is inside the sql list on a local server to learn but it's ret

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744115022a4559130.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信