Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to pass a variable using HTTPService?

I am using HTTPService to run a query with my PHP script. This is to check if the user is banned from my game. I get an error for my trust certificate. How can I pass a variable in ROBLOX (the plr.Name) into a PHP script, to run the query. This is to remove the $_GET function.

This is the code I am using inside of ROBLOX:

hs = game.HttpService

game.Players.PlayerAdded:connect(function(plr)
	local test = hs:GetAsync("link.tk/index.php?uname="..plr.Name, true)
	game.Workspace.Key.Value = test
	print(test)			
end)

And my PHP script is:

<?php
  include('db.php');

  if(isset($_GET['uname'])){
    $uname = $_GET['uname'];
    $banned = DB::query('SELECT banned FROM users WHERE uname=:uname', array(':uname'=>$uname))[0]['banned'];

    if($banned == 1){
      echo "You are blacklisted from this game!";
    }else{
      echo "You are not banned from this game!";
    }
  }

?>

Thanks for the help, Ethan!

1 answer

Use :PostAsync(), like this

local site = 'http://www' --insert site name here
local http = game.HttpService

game.Players.PlayerAdded:connect(function(plr)
	http:PostAsync(site, true)
end)

:GetAsync() gets information about the site, and :PostAsync() sends information to the site.

This discussion is preserved as it was. New answers, comments, and votes are closed.