Http function, posting data - 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: Http function, posting data (
/showthread.php?tid=589617)
Http function, posting data -
bigboy81 - 20.09.2015
I want create banlog on my website using html. In that log i want see who player are banned from admin, and in which time,also ban reason.
I know that i must make in mysql or sql, but i don't want to make in that way.
I looking something in HTTP function but i need some exampl. If i have table for banlog, how i can post data in that table.
If some need code of table i can post.
Re: Http function, posting data -
rinori - 21.09.2015
You need PHP my friend. Learn how to insert data into MySQL through PHP functions.
http://www.w3schools.com/php/php_mysql_insert.asp
http://www.w3schools.com/php/php_mysql_select.asp
Re: Http function, posting data -
Abagail - 21.09.2015
Why would you want to use HTTP interactions and not simply connect to the MySQL server? Though, you can if you absolutely need to use the HTTP(pretty easy to find) function.
e.g:
pawn Код:
#include <a_samp>
#include <a_http>
#include <zcmd>
#include <sscanf2>
CMD:searchbans(playerid, params[])
{
new playerName[MAX_PLAYER_NAME];
if(sscanf(params, "s[25]", playerName))
return SendClientMessage(playerid, 0xFF08080FF, "USAGE: /searchbans [playerName]");
new string[128];
format(string, sizeof string, "http://yoursite.com/banlog.txt?name=%s", playerName);
HTTP(playerid, HTTP_GET, string, "", "OnBanLogSearch");
return 1;
}
forward OnBanLogSearch(index, response_code, data[]);
public OnBanLogSearch(index, response_code, data[])
{
if(IsPlayerConnected(index))
{
if(response_code != 200)
return SendClientMessage(index, 0xFF08080FF, "A HTTP error occured.");
ShowPlayerDialog(index, 0, DIALOG_STYLE_MSGBOX, "Banlog - search", data, "Close", "");
}
return 1;
}
Re: Http function, posting data -
bigboy81 - 21.09.2015
I need example for HTTP_POST function.
But thanks for that e.g
Re: Http function, posting data -
Abagail - 21.09.2015
In that case:
pawn Код:
new string2[128];
format(string2, sizeof string2, "?name=%s&date=%s&reason=%s", name, date, reason);
HTTP(playerid, HTTP_POST, "http://yoursite.com/banlog.txt", string2, "OnBanComplete");