[FX.php List] How to force evaluation of both User and password
fields
Michael Layne
fx at 9degrees.com
Thu Sep 15 14:58:15 MDT 2005
Hi,
The first thing is to use some simple JavaScript validation before
you ever get to the request:
function validForm() {
if (document.form.user.value == "") {
alert("Please provide a user name.");
document. form.user.focus();
return;
}
if (document. form.pass.value == "") {
alert("Please provide an password.");
document. form.pass.focus();
return;
}
document. form.submit();
}
then, what I do is create a calc field in FMP :
email_password = email & "." & password
then in PHP, I concatenate the same on the fly and validate to that
field like so (this is using an email address as a username):
$user = str_replace("@","",$_POST['user']); // forget the
str_replace if not using an email address
$userpass = $user . "." . $_POST['pass'];
$q = new FX($ip, $port);
$q->SetDBData($fmdb,$lay);
$q->AddDBParam('email_password',$userpass);
$r = $q->FMFind();
$d = current($r['data']);
if ($r['foundCount'] == 1) { //successful...
HTH,
Michael
Michael Layne : 9 degrees development : www.9degrees.com :
404.226.7835
On Sep 15, 2005, at 3:39 AM, Jonathan Schwartz wrote:
> I'm using the Dogwalk example to build a logon front end. The
> current script requests both user name and password. When both are
> filled in FMP uses both. However, if one is left blank, then
> FileMaker uses only the one that is filled in.
>
> How do I overcome, preferably to test for field contents as a
> first step.
>
> Current php follows. Thanks
>
> <?
> include ("FX.php");
> include ("prefs.php");
> include ("session_handler.php");
>
>
> $query = new FX($serverIP, $port);
>
> $query->SetDBData ('Walker.fp5', 'web');
>
> $query->AddDBParam ('username', $_POST['name'], 'eq');
> $query->AddDBParam ('password', $_POST['pw'], 'eq');
>
> $result = $query->FMFind();
>
> if ($result['foundCount'] == 1) {
> session_set_save_handler
> ("sess_open","sess_close","sess_read","sess_write","sess_destroy","ses
> s_gc");
> setcookie("sid");
> session_start();
>
> if ($exp) {
> $msg = " Your session has expired. You must login
> again.";
> include_once ("logon.php");
> exit;
> }
>
> $recID = current($result['data']);
>
> session_register("sessWalkerID");
> session_register("sessWalkerName");
>
> $sessWalkerID = $recID['WalkerID'][0];
> $sessWalkerName = $recID['WalkerName'][0];
>
> echo "Loggin in... one moment please";
> echo "<meta http-equiv=refresh content=\"1;url=index.php?
> area=show_schedule\">";
>
> exit;
>
> } else {
> $msg = "Unsucessful login attempt. Please try again.";
> include ("logon.php");
>
> }
>
> ?>
>
> --
>
> Jonathan Schwartz
> Schwartz & Company
> 817 Marin Drive
> Mill Valley, CA 94941
> Phone: 415-381-1852
> jonathan at eschwartz.com - http://www.eschwartz.com
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20050915/225441ae/attachment.html
More information about the FX.php_List
mailing list