Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5422 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I am new to FileMaker via PHP so please be patient with me.

We have a FileMaker XSLT page which shows data from a single record. I have used a form to post the recordID from the XSLT page to a PHP script. The PHP script sends an email and then redirects to a static page which indicates that the email message has been sent.

In the PHP script I am trying to figure out how to use the recordID to call our FMSA 10 for the contents of the email field which will be used of course as the TO: address for the generated email.

I see from the documentation that I will need to tell the PHP page how to contact the FMSA10 and then presumably actually call for the data.

So for contact, complete as appropriate for our installation:

$fm = new FileMaker();

$fm->setProperty('database', 'questionnaire');

$fm->setProperty('hostspec', 'http://192.168.100.110');

$fm->setProperty('username', 'web');

$fm->setProperty('password', 'web');

First question:

For the server contact, can the username and password be blank? For the XSLT pages our accessible fields are all accessible to anyone since they are posted on the web and the XSLT pages did not require a login.

Then:

I plan to tell a variable to hold the email address, so I need help with:

$mail = code to get field contents

I will not need no result escaping since the script can only be called from the XSLT generated page if there is an address in the field.

Second question: Assuming the database contact is setup correctly, how do I call for the content of a single field?

Thanks for taking a look at this issue.

-Erich Wetzel

Posted

Hi Erich,

I'm not sure if you can do unauthenticated access but presumably you could with a guest account. You will need to enable fmphp extended privilege for the guest account. Horrible idea though - it means that anyone from anywhere (i.e. not via your website) can connect to your database server and read or write to your database, run scripts etc. etc. The username and password is designed to secure the connection between your website and the database server, it's not something that your users would have to provide.

To the rest of the question...


$fm = new FileMaker('questionnaire','192.168.100.110');



$recordId = 15;

$record = $fm->getRecordById($recordId);

if( FileMaker::isError($record) ){

echo $record->getCode()." ".$record->getMessage();

} else {

$mail = $record->getField('Email');

}

Posted

Genx,

Thank you. That looks like what I need. Good point about the authentication.

Another point I thought of: My PHP script is currently in the site root folder. If I put the user and password into the PHP script I am currently using, and the result of the script is redirection to a static html page, is the FM user and password available from the web?

I am gradually going to move our XSLT pages to PHP since it is easier for me. The FMS documentation suggests putting the details for the database connection in a different place than in the pages being accessed from the web.

What would you suggest as the most secure standard procedure?

Posted (edited)

Standard procedure is that it's generally put into a seperate folder in the webroot - that way if the username or password changes you've got no real issues. BEST PRACTICE on the other hand says that you should put it in a directory outside of the webroot and include the files from there...

e.g.

If your website is at /var/www/mySiteRoot and all your files and folders are in mySiteRoot then put your connection files into www (a connection file is just a file that has the FileMaker object specified inside it with the username and password pre-filled). Files inside your site root will still be able to include files outside of your site root but you also get the added benefit that if the php association breaks for some reason in the web server and it starts serving up the php files as plaintext without processing htem (very very rare and unlikely) the user will not be able to read a plain text version of the username and password.

Hope that clears it up.

Edited by Guest
Posted

Got it. Thanks for helping me get started. I think that this will be my last startup question...

I have set everything up for a simple test and have a problem with the execution speed. It is taking between 10 and 20 seconds to return the email address in the code below. Full test with a longer PHP page that tests the message contents and sends an email is essentially the same. That seems awful long to me.

The FM Server and Web Server are on the same subnet and have very little traffic at any time. Any idea what would be going on here. I can't have users waiting for a result. With our XSLT pages, the result page time feels immediate and those have much more data in them.

HTML page relevant code:

PHP page entire code:

<?php

$comments = $_POST['message'] ;

$infemail = $_POST['infemail'] ;

$decname = $_POST['decfullname'] ;

$recordid = $_POST['recordid'];

require_once ('FileMaker.php');

$fm = new FileMaker('Active Accounts','192.168.1.2');

$record = $fm->getRecordById('web',$recordid);

$mail = $record->getField('Web Inf email');

echo $mail;

exit;

?>

Posted

This is strange. Half an hour later the result is returned with only a slight pause. The previous post may be irrelevant. I'll test again later to see if it keeps the current pace.

Posted (edited)

No problem. My fault. I left the VPN I was using open. This gave two routes to the same domain. Works great. Thanks for your help getting me into PHP with FileMaker.

I'm trying to give a good rating to the responses in the topic. Clicking the link does nothing. What am I missing? Also do these forums allow a topic to be listed as solved?

Edited by Guest
Posted

Hi Erich,

To be honest I'm not sure ratings has been fully implemented on these forums (or at least i have no idea how to use them lol).

As for marking solved that doesn't really exist either - that being said, you can just write [solved] at the end of your last post - tends to be fairly well recognized in other forums where the feature isn't available.

Anyway, glad I could help.

This topic is 5422 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.