mcyrulik Posted May 23, 2008 Posted May 23, 2008 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?
Genx Posted May 24, 2008 Posted May 24, 2008 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"
mcyrulik Posted May 27, 2008 Author Posted May 27, 2008 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?
Baloo Posted May 27, 2008 Posted May 27, 2008 "$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*/
mcyrulik Posted May 27, 2008 Author Posted May 27, 2008 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.
Genx Posted May 27, 2008 Posted May 27, 2008 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.
Recommended Posts
This topic is 6325 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 accountSign in
Already have an account? Sign in here.
Sign In Now