This example Adobe Acrobat PDF form uses the PHP scripts below to perform a variety of SQL and REST API interactions.
The form needs to be downloaded and opened with either Acrobat or the free Acrobat Reader application to work correctly.

<?php
header("Access-Control-Allow-Origin: *");
header("Content-type: application/vnd.fdf");
header("Cache-Control: no-cache, must-revalidate");
$host = '127.0.0.1';
$db   = 'valucalcprices';
$user = 'valucalcreader';
$pass = 'readerpassword';
$charset = 'utf8mb4';
$options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,];
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$pdo = new PDO($dsn, $user, $pass, $options);
date_default_timezone_set('America/Los_Angeles');
$StatMsg = date('d-m-y h:i:s');
$series = "Diamonds";
$gemtype = "Diamond";
$cuttype = $_POST["CutType"];
$weight = $_POST["Weight"];
$quality = $_POST["Quality"];
$color = $_POST["Color"];
$sql = "select Price from PriceGrid WHERE Series = :series and GemType = :gemtype and CutType = :cuttype and WeightLower <= :weight and WeightUpper > :weight and Quality = :quality and Color = :color";
$stmt = $pdo->prepare($sql);
$stmt->execute(['series' => $series, 'gemtype' => $gemtype, 'cuttype' => $cuttype, 'weight' => $weight, 'quality' => $quality, 'color' => $color]);
$records = $stmt->fetchAll(PDO::FETCH_ASSOC);
$price = $records[0]['Price'];
?>

%FDF-1.2
1 0 obj 
   <</FDF 
<?php
echo "<</Fields[<</T(Status)/V($StatMsg)>> <</T(PerCaratPrice)/V($price)>>]>>";
?>
   >>
endobj
trailer << /Root 1 0 R >>
%%EOF


----------


<?php
header("Access-Control-Allow-Origin: *");
header("Content-type: application/vnd.fdf");
header("Cache-Control: no-cache, must-revalidate");
$endpoint = 'convert';
$access_key = 'YOURFIXER.IOACCESSKEY';
date_default_timezone_set('America/Los_Angeles');
$StatMsg = date('d-m-y h:i:s');
$from = $_POST["From"];
$to = $_POST["To"];
$amount = $_POST["OneUSDollar"];
$ch = curl_init('https://data.fixer.io/api/'.$endpoint.'?access_key='.$access_key.'&from='.$from.'&to='.$to.'&amount='.$amount.'');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
curl_close($ch);
$conversionResult = json_decode($json, true);
$rate = $conversionResult ['info']['rate'];
?>

%FDF-1.2
1 0 obj 
   <</FDF 
<?php
echo "<</Fields[<</T(Status)/V($StatMsg)>> <</T(Result)/V($rate)>>]>>";
?>
   >>
endobj
trailer << /Root 1 0 R >>
%%EOF



----------



<?php
header("Access-Control-Allow-Origin: *");
header("Content-type: application/vnd.fdf");
header("Cache-Control: no-cache, must-revalidate");
$host = "127.0.0.1";
$db   = 'classicmodels';
$user = 'classicmodelsuser01';
$pass = 'user01password';
$charset = 'utf8';
$options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,];
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$pdo = new PDO($dsn, $user, $pass, $options);
date_default_timezone_set('America/Los_Angeles');
$StatMsg = date('d-m-y h:i:s');
$customerNumber = $_POST["CustomerNumber"];
$sql = "select customerNumber, customerName, contactLastName, contactFirstName, phone, addressLine1, addressLine2, city, state, postalCode, country, creditLimit, accountsPayable from customers WHERE customerNumber = :customerNumber";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':customerNumber',(int) $customerNumber, PDO::PARAM_INT);
$stmt->execute();
$records = $stmt->fetchAll(PDO::FETCH_ASSOC);
$customername = $records[0]['customerName'];
$contactlastname = $records[0]['contactLastName'];
$contactfirstname = $records[0]['contactFirstName'];
$phone = $records[0]['phone'];
$addressline1 = $records[0]['addressLine1'];
$addressline2 = $records[0]['addressLine2'];
$city = $records[0]['city'];
$state = $records[0]['state'];
$postalcode = $records[0]['postalCode'];
$country = $records[0]['country'];
$creditlimit = $records[0]['creditLimit'];
$accountspayable = $records[0]['accountsPayable'];
?>

%FDF-1.2
1 0 obj 
   <</FDF 
<?php
echo "<</Fields[<</T(Status)/V($StatMsg)>> <</T(CustomerName)/V($customername)>> <</T(ContactLastName)/V($contactlastname)>> <</T(ContactFirstName)/V($contactfirstname)>> <</T(Phone)/V($phone)>> <</T(AddressLine1)/V($addressline1)>> <</T(AddressLine2)/V($addressline2)>> <</T(City)/V($city)>> <</T(State)/V($state)>> <</T(PostalCode)/V($postalcode)>> <</T(Country)/V($country)>> <</T(CreditLimit)/V($creditlimit)>> <</T(AccountsPayable)/V($accountspayable)>>  ]>>";
?>
   >>
endobj
trailer << /Root 1 0 R >>
%%EOF



----------



<?php
header("Access-Control-Allow-Origin: *");
header("Content-type: application/vnd.fdf");
header("Cache-Control: no-cache, must-revalidate");
$host = "127.0.0.1";
$db   = 'salesorders';
$user = 'user01';
$pass = 'user01password';
$charset = 'utf8mb4';
$options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,];
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$pdo = new PDO($dsn, $user, $pass, $options);
date_default_timezone_set('America/Los_Angeles');
$StatMsg = date('d-m-y h:i:s');
$productnumber = $_POST["ProductNumberLine01"];
$linenumber = "01";
$sql = "select ProductNumber, ProductName, RetailPrice, QuantityOnHand from Products WHERE productnumber = :productnumber";
$stmt = $pdo->prepare($sql);
$stmt->execute(['productnumber' => $productnumber]);
$records = $stmt->fetchAll(PDO::FETCH_ASSOC);
$productname = $records[0]['ProductName'];
$retailprice = $records[0]['RetailPrice'];
$quantityonhand = $records[0]['QuantityOnHand'];
?>

%FDF-1.2
1 0 obj 
   <</FDF 
<?php
echo "<</Fields[<</T(Status)/V($StatMsg)>> <</T(ProductNameLine$linenumber)/V($productname)>> <</T(RetailPriceLine$linenumber)/V($retailprice)>> <</T(QuantityOnHandLine$linenumber)/V($quantityonhand)>>]>>";
?>
   >>
endobj
trailer << /Root 1 0 R >>
%%EOF



----------



<?php
header("Access-Control-Allow-Origin: *");
header("Content-type: application/vnd.fdf");
//header("Content-Type: application/json; charset=utf8mb4");
header("Cache-Control: no-cache, must-revalidate");
$host = "127.0.0.1";
$db   = 'salesorders';
$user = 'user01';
$pass = 'user01password';
$port = "3306";
$charset = "utf8mb4";
$options = [
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
//   PDO::ATTR_EMULATE_PREPARES   => FALSE,
//	 PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode="STRICT_TRANS_TABLES"',
];
$dsn = "mysql:host=$host;dbname=$db;charset=$charset;port=$port";
$pdo = new PDO($dsn, $user, $pass, $options);
date_default_timezone_set('America/Los_Angeles');
$status = date('m/d/Y h:i:s a', time());
$productnumber01 = $_POST["ProductNumberLine01"];
$quantityonhand01 = $_POST["QuantityOnHandLine01"];
$quantityordered01 = $_POST["QuantityLine01"];
$newquantityonhand01 = $quantityonhand01 - $quantityordered01;
$productnumber02 = $_POST["ProductNumberLine02"];
$quantityonhand02 = $_POST["QuantityOnHandLine02"];
$quantityordered02 = $_POST["QuantityLine02"];
$newquantityonhand02 = $quantityonhand02 - $quantityordered02;
$productnumber03 = $_POST["ProductNumberLine03"];
$quantityonhand03 = $_POST["QuantityOnHandLine03"];
$quantityordered03 = $_POST["QuantityLine03"];
$newquantityonhand03 = $quantityonhand03 - $quantityordered03;

try{
    $pdo->beginTransaction();
    $sql = "UPDATE Products SET QuantityOnHand = ?, Status = ? WHERE ProductNumber = ?";
    $stmt = $pdo->prepare($sql);
    $stmt->execute(array($newquantityonhand01,$status,$productnumber01));
	$sql = "UPDATE Products SET QuantityOnHand = ?, Status = ? WHERE ProductNumber = ?";
    $stmt = $pdo->prepare($sql);
    $stmt->execute(array($newquantityonhand02,$status,$productnumber02));
	$sql = "UPDATE Products SET QuantityOnHand = ?, Status = ? WHERE ProductNumber = ?";
    $stmt = $pdo->prepare($sql);
    $stmt->execute(array($newquantityonhand03,$status,$productnumber03));
    $pdo->commit(); 
	$message = "The Quantity On Hand values for all 3 items have been decremented by";
}
catch(Exception $e){
    $message= "Error";
    $pdo->rollBack();
}
?>

%FDF-1.2
1 0 obj 
   <</FDF 
<?php
echo "<</Fields[<</T(Status)/V($status - $message $user)>> <</T(QuantityOnHandLine01)/V($newquantityonhand01)>> <</T(QuantityOnHandLine02)/V($newquantityonhand02)>> <</T(QuantityOnHandLine03)/V($newquantityonhand03)>>  ]>> ";
?>
   >>
endobj
trailer << /Root 1 0 R >>
%%EOF