Http function, posting data
#1

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.
Reply
#2

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
Reply
#3

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;
}
Reply
#4

I need example for HTTP_POST function.
But thanks for that e.g
Reply
#5

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");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)