You shouldn't be writing any PHP files, for the database interaction (unless it's an example of how to). In reality, you should just be spitting out XML to a URL specified (a different URL for PIREP, and a different URL for status, basically a different URL you can set for anything which can be updated), and let me (or whatever system it is) handle what to do with it.
Even in your example PHP files, you should be parsing the XML that your application sends (please don't do it the way FSACARS and Xacars do it now, it's such a pain in the ass to parse), XML is the most pain-free way to go. After dealing with 4 systems now, trust me, this is the best way to go
I would even go to say to look at my FSFK XML configuration (he allows you to put the variables in any format you want for a PIREP, unfortunately, you can't for a status update), so I formatted it into XML:
<FLIGHTDATA>
<PilotID>$@$PilotID$@$</PilotID>
<PilotName>$@$PilotName$@$</PilotName>
<AircraftTitle>$@$AircraftTitle$@$</AircraftTitle>
<AircraftType>$@$AircraftType$@$</AircraftType>
<AircraftTailNumber>$@$AircraftTailNumber$@$</AircraftTailNumber>
<AircraftAirline>$@$AircraftAirline$@$</AircraftAirline>
<FlightNumber>$@$FlightNumber$@$</FlightNumber>
<FlightLevel>$@$FlightLevel$@$</FlightLevel>
<FlightType>$@$FlightType$@$</FlightType>~
<Passenger>$@$Passenger$@$</Passenger>
<Cargo>$@$Cargo$@$</Cargo>
<ZFW>$@$ZFW$@$</ZFW>
<OriginICAO>$@$OriginICAO$@$</OriginICAO>
<OriginGate>$@$OriginGate$@$</OriginGate>
<OriginRunway>$@$OriginRunway$@$</OriginRunway>
<OriginTransitionAltitude>$@$OriginTransitionAltitude$@$</OriginTransitionAltitude>
<DestinationICAO>$@$DestinationICAO$@$</DestinationICAO>
<DestinationGate>$@$DestinationGate$@$</DestinationGate>
<DestinationRunway>$@$DestinationRunway$@$</DestinationRunway>
<DestinationTransitionAltitude>$@$DestinationTransitionAltitude$@$</DestinationTransitionAltitude>
<AlternateICAO>$@$AlternateICAO$@$</AlternateICAO>
<SID>$@$SID$@$</SID>
<STARS>$@$STAR$@$</STARS>
<FlightDistance>$@$FlightDistance$@$</FlightDistance>
<RouteDistance>$@$RouteDistance$@$</RouteDistance>
<OUTTime>$@$OUTTime$@$</OUTTime>
<OFFTime>$@$OFFTime$@$</OFFTime>
<ONTime>$@$ONTime$@$</ONTime>
<INTime>$@$INTime$@$</INTime>
<DayFlightTime>$@$DayFlightTime$@$</DayFlightTime>
<NightFlightTime>$@$NightFlightTime$@$</NightFlightTime>
<BlockTime>$@$BlockTime$@$</BlockTime>
<FlightTime>$@$FlightTime$@$</FlightTime>
<BlockFuel>$@$BlockFuel$@$</BlockFuel>
<FlightFuel>$@$FlightFuel$@$</FlightFuel>
<TOIAS>$@$TOIAS$@$</TOIAS>
<LAIAS>$@$LAIAS$@$</LAIAS>
<ONVS>$@$ONVS$@$</ONVS>
<FlightScore>$@$FlightScore$@$</FlightScore>
<FLIGHTPLAN>
<![CDATA[
$@$FlightPlan$@$
]]>
</FLIGHTPLAN>
<COMMENT>
<![CDATA[
$@$Comment$@$
]]>
</COMMENT>
<FLIGHTCRITIQUE>
<![CDATA[
$@$FlightCritique$@$
]]>
</FLIGHTCRITIQUE>
<FLIGHTMAPS>
<FlightMapJPG>$@$FlightMapJPG$@$</FlightMapJPG>
<FlightMapWeatherJPG>$@$FlightMapWeatherJPG$@$</FlightMapWeatherJPG>
<FlightMapTaxiOutJPG>$@$FlightMapTaxiOutJPG$@$</FlightMapTaxiOutJPG>
<FlightMapTaxiInJPG>$@$FlightMapTaxiInJPG$@$</FlightMapTaxiInJPG>
<FlightMapVerticalProfileJPG>$@$FlightMapVerticalProfileJPG$@$</FlightMapVerticalProfileJPG>
<FlightMapLandingProfileJPG>$@$FlightMapLandingProfileJPG$@$</FlightMapLandingProfileJPG>
</FLIGHTMAPS>
</FLIGHTDATA>
The code to parse this is all of 2 lines. Any other format it's a nightmare (see FSACARS, Xacars), etc.
To parse that (Assuming the POST data is ?xmldata=[the above string])
<?php
$xml = utf8_encode(trim($_POST['xmldata']));
$xml = simplexml_parse_string($xml);
In fact, if you send that exact FSFK format via POST to the URL, it'll make my life so much easier.