Replace  
 
$get_uinfo = mysql_query("SELECT * FROM phpvms_pilots WHERE firstname='".$fname."' AND lastname='".$lname."' AND email='".$email."'");
echo "Result Select: ".mysql_error()."<br>";
$uinfo = mysql_fetch_array( $get_uinfo );
 
with: 
 
$uinfo = PilotData::GetPilotByEmail($email);
 
And replace: 
 
$str = $uinfo['pilotid'];
$pilot_id = str_pad ($str,4,"0",STR_PAD_LEFT);
  
With 
 
$pilot_id = PilotData::GetPilotCode($uinfo->code, $uinfo->pilotid);
 
And then: 
 
$pilot_id = "{$uinfo->firstname} {$uinfo->lastname} {$pilot_id}";
 
Enclose { } around variables, and you can move things around. This way it's using the proper API functions