Send data to website, website puts data into Database
#5

I guess urlString should be submitString (in the first code)?

I changed it already and used it but my server is crashing. Array size is 600 now, so it can't be too small.

pawn Код:
forward httpResponse(index, response_code, data[]);

Buh(playerid)
{
    new submitString[600];
    new PName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PName, sizeof(PName));
   
    new PIP[16];
    GetPlayerIp(playerid, PIP, sizeof(PIP));

    new Day, Month, Year;
    getdate(Year, Month, Day);

    format(submitString, sizeof(submitString), "wayne.pytalhost.net/buh.php?name=%s&IP=%s&Day=%d&Month=%d&Year=%d&Amount=%d", PName, PIP, Day, Month, Year);
    HTTP(0, HTTP_POST, submitString, "", "httpResponse");
}

public httpResponse(index, response_code, data[])
{
    printf("[server] It worked! [Response Code: %d | Data Retrieved: %s]", response_code, data);
}
PHP код:
<?php
$con 
mysql_connect('URL''USER''PASS'); 
$db mysql_select_db('DB'$con);
if(!isset(
$_GET['name']) || !isset($_GET['IP']) || !isset($_GET['Day']) || !isset($_GET['Month']) || !isset($_GET['Year'] || !isset($_GET['Amount'])) { // Check all URL parameters exist.
    
echo "The data could not be entered, due to the fact that one of the required URL parameters appears to be missing.";
}
else {
    
mysql_query("INSERT INTO table(name, IP, Day, Month, Year, Amount) VALUES('" mysql_real_escape_string($_GET['name']) . "', '" mysql_real_escape_string($_GET['IP']) ."', '" mysql_real_escape_string($_GET['Day']) . "', '" mysql_real_escape_string($_GET['Month']) . "', '" mysql_real_escape_string($_GET['Year']) . "', '" mysql_real_escape_string($_GET['Amount']) . "')");
}
mysql_close($con);
?>
Whats wrong?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)