SA-MP Forums Archive
use HTTP to send variables to php. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: use HTTP to send variables to php. (/showthread.php?tid=337053)



use HTTP to send variables to php. - EviLpRo - 24.04.2012

hi people.

how i can use in HTTP to return a variables from the server to php?..
this is currect: ?

pawn Код:
HTTP(playerid,HTTP_POST,"http://xx.xx.xx/index.php",?,onRequestDone());
thank's in advance..


Re: use HTTP to send variables to php. - AndreT - 24.04.2012

The callback must be in quotes and should not contain the round brackets. An example of that would be:
pawn Код:
HTTP(playerid, HTTP_POST, "http://xxx.com/index.php", ?, "onRequestDone");
Also, if I understand you correctly, you've no idea what to feed instead of the ?. I think this should give you an idea:
pawn Код:
HTTP(playerid, HTTP_POST, "http://xxx.com/index.php", "var1=data&var2=data", "onRequestDone");
edit
Ooh, and also, don't forget about the Sockets plugin by BlueG, which allows you to transport data between your gameserver and PHP even better.


Re: use HTTP to send variables to php. - Vince - 24.04.2012

Yes, just use the data parameter to send variables in this format:
Код:
name=evil&foo=bar&session=123
PHP код:
$name $_REQUEST['name']; 



Re: use HTTP to send variables to php. - EviLpRo - 24.04.2012

ok, all right.
but if have some poepole wathing with the page?


Re: use HTTP to send variables to php. - MP2 - 24.04.2012

Make it protected with a password or something, which gets passed with the POST data, or make it only allow connections from your server's IP.

PHP код:
if($_POST['passkey'] != 'passkey_goes_here') die();