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

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

Recommended Posts

Posted

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?

Posted

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"

Posted

"$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*/

Posted

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.

Posted

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.

This topic is 6015 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.