Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP script called by ReportAppUsage.pas that updates a MySQL database with parsed NAME=VALUE parameters from the URL.
<!DOCTYPE html>
<html>
<body>
<?php
$ip = $_SERVER["REMOTE_ADDR"];
echo "ip: $ip ... ";
$mysqli = new mysqli("localhost", "db_user", "db_password", "database");
if ($mysqli->connect_errno) {
echo "Failed to connect: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$cl = parse_url($_SERVER['REQUEST_URI']);
if(count($cl) > 1)
{
$alldata = $cl['query'];
parse_str($alldata, $vals);
$CompName = $mysqli->escape_string($vals['CompName']);
$CompCity = $mysqli->escape_string($vals['CompCity']);
$CompState = $mysqli->escape_string($vals['CompState']);
$AppVer = $vals['AppVer'];
$AppExp = $Vals['AppExpiration'];
$AppActivated = $Vals['AppActivated'];
/* add as many as you're passing from ReportAppUsage */
$ins_sql = sprintf("INSERT INTO app_log(`IPAddress`, `CompName`, `CompCity`, `CompState`, `AppVer`, `AppExpiration`, `Activated`)
VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s')",
$ip, $CompName, $CompCity, $CompState, $AppVer, $AppExp, $AppActivated);
echo " Submitting sql: [$ins_sql] ... ";
if(!$mysqli->query($ins_sql)) {
echo "app_usage insert failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment