Rescue:Post to URL/PHP example

From LogMeInWiki

Jump to: navigation, search
<?php
/*#########################################################################################
This web form will receive data from a LogMeIn Rescue session HTTP post, and write it to a
#MySQL server database.  This script is provided without warranty, and is for use at your
own risk
#########################################################################################*/

error_reporting(E_ERROR);

/*---set up connection string for ACTH and db table---*/
$db_host = "someServerName";
$db_user = "someUser";
$db_pwd = "secretPassword";
$db_name = "someDBname";

//########ensure there is actually session data########

if(($SessionID = $_POST["SessionID"])==0)
   {
die('No session data to record');
   }

//########get the session data from post########

$SessionID = $_POST["SessionID"];
$TechID = $_POST["TechID"];
$TechName = $_POST["TechName"];
$TechDescr = $_POST["TechDescr"];
$Status = $_POST["Status"];
$CField0 = $_POST["CField0"];
$CField1 = $_POST["CField1"];
$CField2 = $_POST["CField2"];
$CField3 = $_POST["CField3"];
$CField4 = $_POST["CField4"];
$CField5 = $_POST["CField5"];
$ChatLog = $_POST["ChatLog"];
$WaitingTime = $_POST["WaitingTime"];
$PickupTime = $_POST["PickupTime"];
$ClosingTime = $_POST["ClosingTime"];

$con = mysql_connect($db_host,$db_user,$db_pwd);

/*--test db connectivity--*/
if(!$con)
{
die('Could not connect to database: ' . mysql_error());
}

//########enter the rescue database########

mysql_select_db($db_name, $con);


//########write the session data########

$sql="INSERT INTO sessions (SessionID,TechID,TechName,TechDescr,Status,CField0,CField1,CField2,CField3,CField4,CField5,ChatLog,WaitingTime,PickupTime,ClosingTime) 
VALUES ('$SessionID', '$TechID', '$TechName', '$TechDescr', '$Status', '$CField0', '$CField1', '$CField2', '$CField3','$CField4', '$CField5', '$ChatLog', '$WaitingTime', '$PickupTime', '$ClosingTime')";


if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Session data added";

//########close the connection to the DB########
mysql_close($con);

//########all done########
?>

Personal tools