
Prerequisite: FileMaker Server and MBS plug-in

FileMaker and Indians
Like OS X Server, FileMaker also uses an Apache web server to provide data for the PHP API or for web publishing. As soon as FileMaker Server has been installed, the Apache web server is usually also available, which FileMaker Server requires for the web release of databases. To call a script in a database hosted by FileMaker Server, we also need the Apache web server installed with FileMaker Server. The underlying principle is simple: we create a PHP file to call a script, which can be called directly from a FileMaker runtime solution via URL using the MBS plugin. The PHP file reads the name of the script and, if necessary, a parameter and passes both details to the corresponding database provided by the FileMaker server.
Create PHP file for data transfer
So first we need to create a PHP file to realize the data transfer from the FileMaker Runtime solution to the FileMaker database shared by the FileMaker Server. The Apache web server of the FileMaker Server stores such files in the directory
Macintosh HD/Library/FileMaker Server/HTTPServer/htdocs
A PHP file must now be created in this directory, which contains the following source code, for example:
<html>
<head>
Sample file
</head>
<body>
<p>
<?php
error_reporting (E_ALL);
require_once ('filemaker.php');
$v = $_POST["parameter"];
$connection =& new FileMaker();
$connection->setProperty('database', 'RemovedFile');
$connection->setProperty('hostspec', 'Server address');
$connection->setProperty('username', 'Username');
$connection->setProperty('password', 'Password');
$cmd = $connection->NewPerformScriptCommand('RemovedFile', 'Scriptname', $v);
$result = $cmd->execute();
if (FileMaker::isError($result))
{
echo $result->message;
}
echo 'Script executed';
?>
</p>
</body>
</html>
The PHP file takes over in the Variable $v takes the script parameter from the FileMaker Runtime solution and passes it in the line "$cmd = $connection->NewPerformScriptCommand('RemoteFile', 'ScriptName', $v);" to the remote FileMaker database shared by the FileMaker Server.
Calling the PHP file from the FileMaker Runtime solution
To be able to execute the PHP file from the FileMaker Runtime solution by passing a parameter, we use the CURL functions of the MBS plugin. Make sure that the MBS plugin has been successfully integrated into the runtime solution. The following script commands are required to execute the created PHP file with parameter passing:
Set variable [$curl; Value:MBS("CURL.New")]
Set variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; "http://www.IhrFileMakerServer.de)]
Set variable [$result; value:MBS("CURL.FormAddKeyValue"; $curl; "parameter"; yourScriptParameter)]
Set variable [$result; Value:MBS("CURL.FormFinish"; $curl; $input)]
Set variable [$result; Value:MBS("CURL.Perform"; $curl)]
Set variable [$result; value:MBS("CURL.Cleanup"; $curl)]
The above commands call the PHP file stored on your FileMaker server and pass a parameter. However, passing parameters is a one-way street: With this method, parameters can only be passed from FileMaker Runtime to the server via CURL - this is not easily possible from the server to FileMaker Runtime.

Markus Schall has been developing individual databases, interfaces and business applications based on Claris FileMaker since 1994. He is a Claris partner, FMM Award winner 2011 and developer of the ERP software gFM-Business. He is also a book author and founder of the M. Schall Publishers.
