[FX.php List] Results of FMNew()

Charles Ross chivalry at mac.com
Mon Dec 12 11:33:07 MST 2005


Andy,

Here's my implementation of what you so generously gave:

<?php
include('constants.php');

//Set the variables to NULL.
$EmailAddress = NULL;
$Password = NULL;

$EmailAddress =$_REQUEST['Username'];
//Create a new variable for the username search that escapes out the  
@ character
$EmailAddressSearch = str_replace('@','\@',$EmailAddress);
$Password=$_REQUEST['Password'];

//Check to see if the username AND password have content. If either  
are empty then redirect to a login failed page
if (strlen($EmailAddress) <=0 or strlen ($Password) <= 0 ) {
		$success = false;
} else {

   $checklogin=new FX($serverIP,$webCompanionPort);
   $checklogin->SetDBData(LAUREL_FILE,'WebLogins');
   $checklogin->SetDBPassword(WEB_PW,WEB_UN);

   $checklogin->AddDBParam('EmailAddress', $EmailAddressSearch ,"eq");
   $checklogin->AddDBParam('Password', $Password, "eq");
   $checkloginResult=$checklogin->FMFind();

   $success = true;
}
?>
<html>
<head>
</head>
<body>
<?php
if($success)
{
   echo "success";
} else {
   echo "no success";
} ?>
</body>

This is in a file called test.php. Here's my form from index.php:

     <form method="post" action="test.php">
       Email Address: <input type="text" name="EmailAddress"  
value=""><br />
       Password: <input type="password" name="Password" value=""><br />
       <input type="submit" name="submit" value="Login">
     </form>

I enter "chivalry at mac.com" and "1234" into the fields and I get a  
page that says "no success". What am I doing wrong here?

I'm considering checks of the entered text similar to your check for  
empty strings. My thinking is that the way I had it before would find  
the record if the search was correct, and would sometimes find the  
record if the search was incorrect, but wouldn't not find the record  
if the search was correct. So, I let the regular search happen, and  
if it does find something, I check the $_POST variables against the  
text in the fields in the actual record and make sure it's an exact  
match. This is the workaround I've come up with. Any thoughts?

Thanks,
Chuck

On Dec 12, 2005, at 6:59 AM, andy at fmpug.com wrote:

> <?php
> //Set the variables to NULL.
> $Username = NULL;
> $Password = NULL;
>
> $Username =$_REQUEST['Username'];
> //Create a new variable for the username search that escapes out  
> the @ character
> $UsernameSearch = str_replace('@','\@',$Username);
> $Password=$_REQUEST['Password'];
>
> Check to see if the username AND password have content. If either  
> are empty then redirect to a login failed page
> if (strlen($Username) <=0 or strlen ($Password) <= 0 ) {
> 		header ("Location:login_failed.php");
> 		exit();
> }
>
> $checklogin=new FX($serverIP,$webCompanionPort);
> $checklogin->SetDBData('filename','layout');
> $checklogin->SetDBPassword('password','accountname');
>
> $checklogin->AddDBParam('username', $UsernameSearch ,"eq");
> $checklogin->AddDBParam('password', $Password, "eq");
> $checkloginResult=$checklogin->FMFind();
>
> ?>

Chuck Ross
Author - The Book of AppleScript Studio
Contributor/Technical Editor - The Book of FileMaker
Contributing Editor - About This Particular Macintosh
Contributing Writer - ISO FileMaker Magazine
mailto:chivalry at mac.com
AIM:mer0dyn
web:http://homepage.mac.com/chivalry/




More information about the FX.php_List mailing list