May 23, 200817 yr I have a PHp solution that uses a login page(authentication.php) to log a user in. If the login is successful, no problem, go to the index page. If the login is unsuccessful, the page just refreshes. Is there a way to capture what FM returns from a login action?
May 24, 200817 yr if( FileMaker::isError( $login_result ) ) { echo $login_result->getMessage(); } To be fair though, probably better to just echo out "Username or Password does not match any accounts in our system"
May 27, 200817 yr Author Thanks, but where does $login_result get set? I assume I have to set it from an object that Filemaker returns, but what is that object?
May 27, 200817 yr "$login_result" gets set wherever you send the user's login data to Filmaker in authentication.php. If you're using their credentials to login to create the Filemaker object it's here: $fm = new FileMaker('myDB', "myServer","user", "pw"); On a successful login the constructor returns a Filemaker object, on an unsuccessful login the constructor returns a Filemaker_Error object. If you are preforming a find in a users table it's here: $found_set = $fm->newFindCommand('All'); $found_set->addFindCriterion("user", $_REQUEST['user']); $found_set->addFindCriterion("pw", $_REQUEST['pw']); $result = $found_set->execute(); On a successful login $result will contain a FileMaker_Result object. If it doesn't find the user in the table $result will contain a Filemaker_Error object. Genx is right you should write your own login error handling message because in the 2 cases above: echo $fm->getMessage();/*outputs Error: Communication Error: (22) The requested URL returned error: 401*/ echo $result->getMessage(); /*outputs Error: No records match the request*/
May 27, 200817 yr Author Thanks guys. I had planned on writing my own thing. I just wanted to be able to display something, rather than just have the page refresh back to a blank login form - That seems a little vague and not good programming.
May 27, 200817 yr I wouldn't recommend that you actually output what FM returns - not useful to the user. Better bet would be output a generic message if the account login failed i.e. "username or password is incorrect" or another message if anything else happens "the database is currently unavailable, please try again later." Then, go ahead and write your error to somewhere useful.
Create an account or sign in to comment