Jump to content

fmpros

Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by fmpros

  1. Thanks a bunch for taking the time to post a solution. I'll give it a try. Much appreciated! The FileMaker Pro PHP API is pretty slick. I'm certain we will see more FMP/PHP developers as time goes on. Thanks again!
  2. I'm trying to build a login process that appears to be beyond my experience. I'm using PHP with FileMaker Pro as a backend, although I believe the FMP specific calls are irrelevant as the problem therein lies with my PHP code. Here is my login script that is included on my login page. I need users to be redirected to one page or another depending on the context. The site I'm building is intended to provide test results. Users must register their test ID after creating valid login credentials. Users will be able to register more than one test. If the user has previously registered tests, I need the PHP to redirect the user to one of two pages after logging in. [*]If a user is prompted to login via my "results" page, I'd like the user to be forwarded to the page that displays their test results. [*]If a user is prompted to login via my "test registration" page, I'd like the user to end up on my test registration form I know that I can do this if I build two separate login forms/scripts although I'd LOVE to know how to do this dynamically. Ideally, I'd like to use the one script and one login form. Here is the script I have written: <?php if(!session_id()) session_start();?> $error = ''; $from = $_GET['from']; if(POST('action') == 'login') { $userFind = $db->newFindCommand('fmp_layout'); $userFind->addFindCriterion('Email','=='.POST('email')); $userFind->addFindCriterion('Password','=='.POST('password')); $userResult = $userFind->execute(); if(FileMaker::isError($userResult)) { $error = 'Incorrect username or password'; }else{ if(!session_id()) session_start(); session_cache_limiter('private'); $cache_limiter = session_cache_limiter(); /* set the cache expire to 30 minutes */ session_cache_expire(30); $cache_expire = session_cache_expire(); $records = $userResult->getRecords(); $recid = $records[0]->getRecordId(); $record = $db->getRecordById('fm_layout', $recid); $id = $record->getField('fm_field'); $_SESSION['login_user'] = POST('email'); $_SESSION['login_pass'] = POST('password'); $_SESSION['recid'] = $recid; $_SESSION['id'] = $id; $_SESSION['isLoggedin'] = 'true'; if(!isset($_SESSION['from']) { header('Location: page1.php'); exit(); }else{ header('Location: page2.php'); exit(); } } } if(GET('action') == 'logout') { if(!session_id()) session_start(); //erase all session variables $_SESSION = array(); //destroy the session. session_destroy(); $error = 'You have been logged out'; } ?> For whatever reason, I can't get the "header" calls to work correctly. What am I doing wrong? Any insight would be greatly appreciated. Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.