Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Need help with login page in PHP

Featured Replies

  • Newbies

Im trying to create a simple login page. I need for both user and password fields to match to validate the user, but if only user or password is filled the user with still have access. Took some code from Advanced filemaker pro 6 Web Development book but still doesnt work. Here's my code for my result page.

<?php

include_once('FX/FX.php');

include_once('FX/server_data.php');

include_once('FX/FMErrors.php');

$search=new FX($serverIP,$webCompanionPort);

$search->SetDBData ("db.fp5","main");

$search->SetDBPassword ("123");

$search->AddDBParam('user',$_POST['user'], 'eq');

$search->AddDBParam('pass',$_POST['pass'], 'eq');

$searchResult=$search->FMFind();

if ($searchResult['foundCount']==1)

{

include ("loginres.php");

}

else

{

include ("loginerror.php");

}

?>

  • Author
  • Newbies

Im trying to create a simple login page. I need for both user and password fields to match to validate the user, but if only user or password is filled the user with still have access. Took some code from Advanced filemaker pro 6 Web Development book but still doesnt work. Here's my code for my result page.

<?php

include_once('FX/FX.php');

include_once('FX/server_data.php');

include_once('FX/FMErrors.php');

$search=new FX($serverIP,$webCompanionPort);

$search->SetDBData ("db.fp5","main");

$search->SetDBPassword ("123");

$search->AddDBParam('user',$_POST['user'], 'eq');

$search->AddDBParam('pass',$_POST['pass'], 'eq');

$searchResult=$search->FMFind();

if ($searchResult['foundCount']==1)

{

include ("loginres.php");

}

else

{

include ("loginerror.php");

}

?>

  • Author
  • Newbies

Im trying to create a simple login page. I need for both user and password fields to match to validate the user, but if only user or password is filled the user with still have access. Took some code from Advanced filemaker pro 6 Web Development book but still doesnt work. Here's my code for my result page.

<?php

include_once('FX/FX.php');

include_once('FX/server_data.php');

include_once('FX/FMErrors.php');

$search=new FX($serverIP,$webCompanionPort);

$search->SetDBData ("db.fp5","main");

$search->SetDBPassword ("123");

$search->AddDBParam('user',$_POST['user'], 'eq');

$search->AddDBParam('pass',$_POST['pass'], 'eq');

$searchResult=$search->FMFind();

if ($searchResult['foundCount']==1)

{

include ("loginres.php");

}

else

{

include ("loginerror.php");

}

?>

Here is one that works for me:

// handle a new login

$Query->AddDBParam("last_name", "==");

$Query->AddDBParam("last_name", $_POST["name"]);

$Query->AddDBParam("Password", "==");

$Query->AddDBParam("Password", $_POST["password"]);

Good Luck.

Garry

Here is one that works for me:

// handle a new login

$Query->AddDBParam("last_name", "==");

$Query->AddDBParam("last_name", $_POST["name"]);

$Query->AddDBParam("Password", "==");

$Query->AddDBParam("Password", $_POST["password"]);

Good Luck.

Garry

Hi, s! Gary's use of the "==" forces an EXACT SEARCH, which means that if someone submits a NULL or "" for either of the fields, then it will not match. You could also use JavaScript to check to make sure fields are not empty before submitting the form. I haven't really checked out FX.php yet, though.

--ST

Using Java in the preposting page to check for empty fields is a more eligant way as Steve suggested.

I also prefer to capture the posting variables before the query. I have seen some circumstances where putting $_POST['variable'] directly into the AddDBParam crashes the code (dont ask me why).

$user=$_REQUEST['user'] //$_REQUEST works in replace of both $_POST, $_GET, etc

$pass=$_REQUEST['pass']

Then the code that Gary suggested. but you could add an if statement to check the fields first:

if($user!='' && $pass!='') {

$Query->AddDBParam("last_name", "==");

$Query->AddDBParam("last_name", $user);

$Query->AddDBParam("Password", "==");

$Query->AddDBParam("Password", $pass);

}

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.