3 Replies Latest reply on Dec 27, 2014 9:24 AM by ebisu

    Change password in PHP custom web

    ebisu

      I'm using two global fields ("_x_pw" and "_x_pw_new") to perform the "Change Password" script.

      The script is quite simple with only one step "Change Password"(Old password:_x_pw; New password:_x_pw_new; no dialog).

      It works well in FMPro13, but doesn't work on web.

       

      Users privilege is allowed to change password.

      The values seem passed successfully (see line 7-8), but the script gave an error (by line 14). Is this caused by global fields?

      The output page is like:

       

        pass,newpass

        admin,pass

        213User account and/or password does not exist.

       

      Here is the code I picked up.

       

        <?php

        header("Content-Type: text/html; charset = utf-8");

        ini_set('display_error',1);

        require_once('FileMaker.php');

        require_once("secure.php");

       

      1 if($_POST['oldpass']==$_SESSION['account']['password']){

      2      $findAny = $fm->newFindAnyCommand('Program_web');

      3      $anyRecord = $findAny->execute();

      4      $record = $anyRecord->getFirstRecord();

      5      $record -> setField('_x_pw', $_POST['oldpass']);

      6      $record -> setField('_x_pw_new', $_POST['newpass']);

      7      echo $record->getField('_x_pw'). ",". $record->getField('_x_pw_new')."<br>";

      8      echo $_SESSION['account']['username']. ",". $_SESSION['account']['password']."<br>";

      9      $performChangePass = $fm->newPerformScriptCommand('Program_web', 'Change Password');

      10      $changeResult = $performChangePass->execute();

           }


      11 if(FileMaker::isError($changeResult)){

      12      $error_cd = $changeResult->code;

      13      $error_mes = $changeResult->getMessage();

      14      echo $error_cd . $error_mes;

           }

           ?>

      I appreciate anyone who is helping me.