5 Replies Latest reply on Oct 18, 2012 10:00 AM by MattiasThorslund

    Problem with PHP Solution

    DarrenTerry

      Title

      Problem with PHP Solution

      Your post

      Hi all:  I've built a PHP-based CWP web interface to an existing FM database.  I built an empty web front-end file (sort of like the UI file in the separation model, pointed at the main file as if it were the data file), and the PHP connection is aimed at that web front end file.  On my local MacBook Pro (running Lion 10.7.2 and FMS 11.0.4), it all works perfectly.

      When I put the web front-end file (WEB_FE) and PHP pages on the client's server (an OS X Server Leopard machine running 10.5.8 and FMS 11.0.4), the browser hangs with a white screen at the login processing page.  My question:  What should I be checking for, beyond the obvious (see below)?

      Details:

      All the data is in the Data file.  The WEB_FE file is built like an interface file in the sep model.  The index.php page is a login form with Account and Password fields.  It submits to login_process.php, which pushes the submitted Account and Password values to elements of the session variable array ($_SESSION['account'] and $_SESSION['password'], respectively).  Then it calls a fm_include.php file that establishes the FM connection.  It does that this way:

      $file = 'WEB_FE';
      $server = 'ip address of the server here';
      $user = $_SESSION['account'];
      $pass = $_SESSION['password'];

      $DB = new FileMaker($file, $server, $user, $pass);

      Then in login_process, after calling fm_include, I do a find in the USER table of WEB_FE for the user's name in a login_id field:

      $find = $DB->newFindCommand('USER');
      $find->addFindCriterion('Login_ID', $user);
      $result = $find->execute();

      This allows me 2 levels of redundancy:  the supplied account and password must be able to log into the db, and the account must have a USER record defined in the database also.  If the find throws any error at all, I redirect the user to index.php with an error message showing, and clear out $_SESSION['account'] and $_SESSION['password'].  If no error is thrown, then I assume a successful login and find operation, and redirect to main.php (which is sort of a dashboard of the system).  I hope that's clear.

      On any normal day, the user would never see login_process.php.  Once they hit submit on index.php, they'd either be immediately taken to main.php (logged in), or index.php would immediately refresh with an error message.  This works fine on my Lion laptop.

      On the client's Leopard server, when the user hits Submit on index.php, the browser draws a blank screen at login_process.php and dies there.  It really seems as if fm_include can't make a successful connection to the db.

      In the FMS Admin Console, php is enabled for both WEB_FE and the back-end data file.  In the FileMaker Server Overview screen of FM Server Admin Tool, the Web Server is green, and PHP says "On".  In the Databases tab, both the data file and WEB_FE have PHP checked.  The permissions on the php files all appear to be fine (I was thinking that this sounds an awful lot like a permissions problem).  

      To stress again:  The PHP code and the database itself work perfectly on my machine, so I know it's not a typo or something like that in the php code.  (The only difference in the code on my machine vs. the client's server is the IP address of the db server in the fm_include page).  

      What I've tried:

      - I modified login_process to skip the authentication, force-set the $_SESSION variables, and redirect to main.php.   That page draws white. (That page calls the same fm_include page, which instantiates the $DB connection object.  If that command is throwing an error, as if the php pages are unable to connect to the db, then it would cause main.php to draw white also).  

      - I modified login_process to aim at the FileMaker_sample database that ships with FM Server, rather than my WEB_FE file.  The sample database opens with the default Admin account (no password).  I modified the page to submit the user-supplied account and password to the db, and to do a findAny in the main table.  On any error, I echo "there was a problem" and exit.  Otherwise, I pull a field from the found record and echo that.  Logging in against that modified login_process page continues to draw a white screen. login_process is unable to connect to the FileMaker_sample db in the same way that it cannot connect to my WEB_FE file.

      - I double-checked the Apache settings in the Mac OS X Server Admin console.  I didn't see anything unusual, but I'm no OS X uber-guru.  

      What do you suggest I should look for to solve this problem?  The client has a pretty savvy Mac OS IS guy who's helping me troubleshoot this (and he's fairly familiar with FMP and FMS also), and he doesn't see anything obviously wrong with the Apache setup or FMS.  I'm at my wit's end on this one, and would appreciate any help anyone can give me.

      regards,

      Darren Terry

      darren_terry@pdm-inc.com