7 Replies Latest reply on Mar 30, 2016 2:23 AM by beverly

    Unable to retrieve data from filemaker database using php?

    rj.rijo

      Unable to retrieve some of the fields from the filemaker database using php. Im new to this.

      Date of Birth, Address and Notes these three are the fields that are not retrieved in php form.

      this is the code:

      <!DOCTYPE html>

      <html lang="en">

       

       

      <?php

      include ("dbaccess.php");

      ?>

       

       

       

       

      <?php

      //Set message variable for IIS server. Any variables left empty and not defined on IIS will throw a 500 error.

      $message = "";

       

       

      # Check the POST name to see if the user clicked the Save button.

      if (isset($_POST['save']) and $_POST['save'] == 'Save') {

        # Tell FileMaker to edit the record.

        # Before the data is sent back to the database you can validate it here. No examples of validation are shown in the example.

        # Please see the demo for InsertRecordValidation.php

        # This is just a straight forward insert demo.

        $edit = $fm->newEditCommand('Contacts', $_POST['id']);

        # Set the fields with the values from the $_POST superglobal

        $edit->setField('Title', $_POST['Title']);

        $edit->setField('FirstName', $_POST['FirstName']);

        $edit->setField('LastName', $_POST['LastName']);

        $edit->setField('FullName', $_POST['FullName']);

        $edit->setField('Designation', $_POST['Designation']);

        $edit->setField('BirthDate', $_POST['BirthDate']);

        $edit->setField('Mission', $_POST['Mission']);

        $edit->setField('Church', $_POST['Church']);

        $edit->setField('Address', $_POST['Address']);

        $edit->setField('PostOffice', $_POST['PostOffice']);

        $edit->setField('City', $_POST['City']);

        $edit->setField('PIN', $_POST['PIN']);

        $edit->setField('State', $_POST['State']);

        $edit->setField('District', $_POST['District']);

        $edit->setField('Block', $_POST['Block']);

        $edit->setField('OfficePhone', $_POST['OfficePhone']);

        $edit->setField('HomePhone', $_POST['HomePhone']);

        $edit->setField('Mobile', $_POST['Mobile']);

        $edit->setField('Email', $_POST['Email']);

        $edit->setField('TypeOfMinistry', $_POST['TypeOfMinistry']);

        $edit->setField('MainMinistry', $_POST['MainMinistry']);

        $edit->setField('YearOfData', $_POST['YearOfData']);

        $edit->setField('DataCollectedBy', $_POST['DataCollectedBy']);

        $edit->setField('TeamLeaderName', $_POST['TeamLeaderName']);

        $edit->setField('Notes', $_POST['Notes']);

        //Date and TimeStamp are disabled in the POST, no need to update the values

        //$edit->setField('Date', $_POST['Date']);

        //$edit->setField('TimeStamp', $_POST['TimeStamp']);

        # Execute the newEditCommand

        //$edit->execute();

       

       

        # Update the message variable to tell the user the record has been saved.

        //$message = '<p>Your changes have been saved</p>';

       

        $result = $edit->execute();

      if ($fm->isError($result))

      {

           print "Error:" . $result->getMessage();

      }

      else

      {

           print "Your changes have been saved.";

      }

       

       

      }

       

       

      # Make sure there is a record that corresponds to the RecordID. If not, stop the script.

      if (empty($_GET['id'])) {

          die('The record no longer exists.');

      }

       

       

      # Find the record using getRecordByID using the id passed in the URL

      $record = $fm->getRecordById('Contacts', $_GET['id']);

       

       

      # Create variables for all the fields for output in the html

      $ContactID = $record->getField('ContactID');

      $Title = $record->getField('Title');

      $FirstName = $record->getField('FirstName');

      $LastName = $record->getField('LastName');

      $FullName = $record->getField('FullName');

      $Designation = $record->getField('Designation');

      $BirthDate = $record->getField('BirthDate');

      $Mission = $record->getField('Mission');

      $Church = $record->getField('Church');

      $Address = $record->getField('Address');

      $PostOffice = $record->getField('PostOffice');

      $City = $record->getField('City');

      $PIN = $record->getField('PIN');

      $State = $record->getField('State');

      $District = $record->getField('District');

      $Block = $record->getField('Block');

      $OfficePhone = $record->getField('OfficePhone');

      $HomePhone = $record->getField('HomePhone');

      $Mobile = $record->getField('Mobile');

      $Email = $record->getField('Email');

      $TypeOfMinistry = $record->getField('TypeOfMinistry');

      $MainMinistry = $record->getField('MainMinistry');

      $YearOfData = $record->getField('YearOfData');

      $DataCollectedBy = $record->getField('DataCollectedBy');

      $TeamLeaderName = $record->getField('TeamLeaderName');

      $Notes = $record->getField('Notes');

       

       

      ?>

       

       

      <head>

       

       

          <meta charset="utf-8">

          <meta http-equiv="X-UA-Compatible" content="IE=edge">

          <meta name="viewport" content="width=device-width, initial-scale=1">

          <meta name="description" content="">

          <meta name="author" content="">

       

       

          <title>IHF</title>

       

       

          <!-- Bootstrap Core CSS -->

          <link href="css/bootstrap.min.css" rel="stylesheet">

       

       

          <!-- Custom CSS -->

          <link href="css/landing-page.css" rel="stylesheet">

       

       

          <!-- Custom Fonts -->

          <link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

          <link href="http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">

       

       

          <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->

          <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->

          <!--[if lt IE 9]>

              <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>

              <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>

          <![endif]-->

       

       

      </head>

       

       

      <body>

       

       

          <?php

        include 'nav.php';

        ?>

       

       

          <!-- Header -->

          <a name="about"></a>

          <div class="intro-header">

              <div class="container">

       

       

                 

      <div class="container"><h1>Contact Profile</h1></div>

       

       

      <div id="exTab1" class="container">

      <ul  class="nav nav-pills">

        <li class="active">

                <a  href="contact_list.php">Contact List</a>

        </li>

        </ul>

       

       

        <br>

        </div>

       

      <div id="exTab1" class="container">

      <ul  class="nav nav-pills">

        <li class="active">

              <a  href="#1a" data-toggle="tab">Contact Details</a>

        </li>

        <li><a href="#2a" data-toggle="tab">Gathering Details</a>

        </li>

        <li><a href="#3a" data-toggle="tab">Official Details</a>

        </li>

        </ul>

       

       

        <div align="left" class="tab-content clearfix">

         <div class="tab-pane active" id="1a">

        

      <form action="edit_record.php?id=<?php echo $_GET['id']; ?>" method="post">

          <input type="hidden" name="id" value="<?php echo $_GET['id']; ?>" />

       

       

        <table style="width:100%">

        <tr>

        <td width="33%">

        <table>

        <tr>

              <th>ContactID</th>

              <td><?php echo $ContactID; ?></td>

            </tr>

        <tr>

        <td width="33%"><label class="desc" id="Title" for="Title">

          Title :

          </label></td>

        <td width="33%"><select id="Title" name="Title" class="field select medium" style="background-color:#FCF5D8;color:black;" tabindex="11">

            <option value="<?php echo $Title; ?>"><?php echo $Title; ?></option>

         

          </select></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="FirstName" for="FirstName">First Name : </label></td>

        <td width="33%"><input size="20%" id="FirstName" name="FirstName" type="text" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $FirstName; ?>" ></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="LastName" for="LastName">Last Name : </label></td>

        <td width="33%"><input size="20%" id="LastName" name="LastName" type="text" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $LastName; ?>" size="8" tabindex="1"></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="FullName" for="FullName">Full Name : </label></td>

        <td width="33%"><?php echo $FullName; ?></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="Designation" for="Designation">

          Designation :

          </label></td>

        <td width="33%"><select id="Designation" name="Designation" class="field select medium" style="background-color:#FCF5D8;color:black;" tabindex="11">

            <option value="<?php echo $Designation; ?>"><?php echo $Designation; ?></option>

          </select></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="title106" for="Field106">

          Gender :

          </label></td>

        <td width="33%"><input id="radioDefault_5" name="Field5" type="hidden" value="">

        <input id="Field5_0" name="Field5" type="radio" value="Male" tabindex="5" checked="checked">

            <label class="choice" for="Field5_0">Male</label>&nbsp&nbsp&nbsp

        <input id="Field5_1" name="Field5" type="radio" value="Female" tabindex="6">

              <label class="choice" for="Field5_1">Female</label></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="BirthDate" for="BirthDate">Date of Birth : </label></td>

        <td width="33%"><input size="20%" id="BirthDate" name="BirthDate" type="date" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $BirthDate; ?>" size="8" tabindex="1"></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="Mission" for="Mission">Mission : </label></td>

        <td width="33%"><input id="Mission" name="Mission" type="text" size="20%" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $Mission; ?>" size="8" tabindex="1"></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="Church" for="Church">Church : </label></td>

        <td width="33%"><input id="Church" name="Church" type="text" size="20%" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $Church; ?>" size="8" tabindex="1"></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="Address" for="Address">Address : </label></td>

        <td width="33%"><textarea id="Address" name="Address" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $Address; ?>" size="8" tabindex="1"></textarea></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="PostOffice" for="PostOffice">PostOffice : </label></td>

        <td width="33%"><input id="PostOffice" name="PostOffice" type="text" size="20%" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $PostOffice; ?>" size="8" tabindex="1"></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="City" for="City">City/Town : </label></td>

        <td width="33%"><input id="City" name="City" type="text" size="20%" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $City; ?>" size="8" tabindex="1"></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="PIN" for="PIN">Pin : </label></td>

        <td width="33%"><input id="PIN" name="PIN" type="text" size="20%" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $PIN; ?>" size="8" tabindex="1"></td>

        </tr>

        </table>

        </td>

        <td width="33%"><table>

        <tr>

        <td width="33%"><label class="desc" id="title106" for="Field106">

          State :

          </label></td>

        <td width="33%"><select id="State" name="State" class="field select medium" style="background-color:#FCF5D8;color:black;" tabindex="11">

            <option value="<?php echo $State; ?>"><?php echo $State; ?></option>

          </select></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="title106" for="Field106">

          District :

          </label></td>

        <td width="33%"><select id="District" name="District" class="field select medium" style="background-color:#FCF5D8;color:black;" tabindex="11">

            <option value="<?php echo $District; ?>"><?php echo $District; ?></option>

          </select></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="title106" for="Field106">

          Block :

          </label></td>

        <td width="33%"><select id="Block" name="Block" class="field select medium" style="background-color:#FCF5D8;color:black;" tabindex="11">

            <option value="<?php echo $Block; ?>"><?php echo $Block; ?></option>

          </select></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="title106" for="Field106">

          Director :

          </label></td>

        <td width="33%"><input id="Director_5" name="Director5" type="hidden" value="">

        <input id="Director5_0" name="Director5" type="radio" value="Director" tabindex="5" checked="checked">

            <label class="choice" for="Director5_0">Yes</label>&nbsp&nbsp&nbsp

        <input id="Director5_1" name="Director5" type="radio" value="No" tabindex="6">

              <label class="choice" for="Director5_1">No</label></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="title106" for="Field106">

          Coordinator :

          </label></td>

        <td width="33%"><input id="Coordinator_5" name="Coordinator5" type="hidden" value="">

        <input id="Coordinator5_0" name="Coordinator5" type="radio" value="Coordinator" tabindex="5" checked="checked">

            <label class="choice" for="Coordinator5_0">Yes</label>&nbsp&nbsp&nbsp

        <input id="Coordinator5_1" name="Coordinator5" type="radio" value="No" tabindex="6">

              <label class="choice" for="Coordinator5_1">No</label></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="title106" for="Field106">

          Team Leader :

          </label></td>

        <td width="33%"><input id="Team_Leader_5" name="Team_Leader5" type="hidden" value="">

        <input id="Team_Leader5_0" name="Team_Leader5" type="radio" value="Team_Leader" tabindex="5" checked="checked">

            <label class="choice" for="Team_Leader5_0">Yes</label>&nbsp&nbsp&nbsp

        <input id="Team_Leader5_1" name="Team_Leader5" type="radio" value="No" tabindex="6">

              <label class="choice" for="Team_Leader5_1">No</label></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="title106" for="Field106">

          Field Worker :

          </label></td>

        <td width="33%"><input id="Field_Worker_5" name="Field_Worker5" type="hidden" value="">

        <input id="Field_Worker5_0" name="Field_Worker5" type="radio" value="Field_Worker" tabindex="5" checked="checked">

            <label class="choice" for="Field_Worker5_0">Yes</label>&nbsp&nbsp&nbsp

        <input id="Field_Worker5_1" name="Field_Worker5" type="radio" value="No" tabindex="6">

              <label class="choice" for="Field_Worker5_1">No</label></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="title106" for="Field106">

          Office Staff :

          </label></td>

        <td width="33%"><input id="Office_Staff_5" name="Office_Staff5" type="hidden" value="">

        <input id="Office_Staff5_0" name="Office_Staff5" type="radio" value="Office_Staff" tabindex="5" checked="checked">

            <label class="choice" for="Office_Staff5_0">Yes</label>&nbsp&nbsp&nbsp

        <input id="Office_Staff5_1" name="Office_Staff5" type="radio" value="No" tabindex="6">

              <label class="choice" for="Office_Staff5_1">No</label></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="title106" for="Field106">

          Volunteer :

          </label></td>

        <td width="33%"><input id="Volunteer_5" name="Volunteer5" type="hidden" value="">

        <input id="Volunteer5_0" name="Volunteer5" type="radio" value="Volunteer" tabindex="5" checked="checked">

            <label class="choice" for="Volunteer5_0">Yes</label>&nbsp&nbsp&nbsp

        <input id="Volunteer5_1" name="Volunteer5" type="radio" value="No" tabindex="6">

              <label class="choice" for="Volunteer5_1">No</label></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="OfficePhone" for="OfficePhone">Office Phone : </label></td>

        <td width="33%"><input id="OfficePhone" name="OfficePhone" type="text" size="20%" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $OfficePhone; ?>" size="8" tabindex="1"></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="HomePhone" for="HomePhone">Home Phone : </label></td>

        <td width="33%"><input id="HomePhone" name="HomePhone" type="text" size="20%" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $HomePhone; ?>" size="8" tabindex="1"></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="Mobile" for="Mobile">Mobile : </label></td>

        <td width="33%"><input id="Mobile" name="Mobile" type="text" size="20%" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $Mobile; ?>" size="8" tabindex="1"></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="Email" for="Email">Email : </label></td>

        <td width="33%"><input id="Email" name="Email" type="text" size="20%" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $Email; ?>" size="8" tabindex="1"></td>

        </tr>

        </table>

        </td>

        <td width="33%"><table>

        <tr>

        <td width="33%"><label class="desc" id="title106" for="Field106">

          Paid :

          </label></td>

        <td width="33%"><input id="Volunteer_5" name="Volunteer5" type="hidden" value="">

        <input id="Volunteer5_0" name="Volunteer5" type="radio" value="Volunteer" tabindex="5" checked="checked">

            <label class="choice" for="Volunteer5_0">Yes</label>&nbsp&nbsp&nbsp

              <label class="choice" for="Volunteer5_1">No</label></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="TypeOfMinistry" for="TypeOfMinistry">

          Type of Ministry :

          </label></td>

        <td width="33%"><select id="TypeOfMinistry" name="TypeOfMinistry" class="field select medium" style="background-color:#FCF5D8;color:black;" tabindex="11">

            <option value="<?php echo $TypeOfMinistry; ?>"><?php echo $TypeOfMinistry; ?></option>

          </select></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="MainMinistry" for="MainMinistry">Main Ministry : </label></td>

        <td width="33%"><input id="MainMinistry" name="MainMinistry" type="text" size="20%" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $MainMinistry; ?>" size="8" tabindex="1"></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="title106" for="Field106">

          Present Status :

          </label></td>

        <td width="33%"><input id="presentstatus_5" name="presentstatus5" type="hidden" value="">

        <input id="presentstatus5_0" name="presentstatus5" type="radio" value="Active" tabindex="5" checked="checked">

            <label class="choice" for="presentstatus5_0">Active</label>&nbsp&nbsp&nbsp

              <label class="choice" for="presentstatus5_1">Inactive</label></td>

        <label class="choice" for="presentstatus5_2">Others</label></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="YearOfData" for="YearOfData">Year of Data : </label></td>

        <td width="33%"><input id="YearOfData" name="YearOfData" type="text" size="20%" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $YearOfData; ?>" size="8" tabindex="1"></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="title106" for="Field106">

          Christian Directory Permission :

          </label></td>

        <td width="33%"><input id="christiandirectorypermission_5" name="christiandirectorypermission5" type="hidden" value="">

        <input id="christiandirectorypermission5_0" name="christiandirectorypermission5" type="radio" value="Yes" tabindex="5" checked="checked">

            <label class="choice" for="christiandirectorypermission5_0">Yes</label>&nbsp&nbsp&nbsp

              <label class="choice" for="christiandirectorypermission5_1">No</label></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="DataCollectedBy" for="DataCollectedBy">Data Collected By : </label></td>

        <td width="33%"><input id="DataCollectedBy" name="DataCollectedBy" type="text" size="20%" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $DataCollectedBy; ?>" size="8" tabindex="1"></td>

        </tr>

        <tr>

        <td width="33%"><label class="desc" id="TeamLeaderName" for="TeamLeaderName">Teamleader Name : </label></td>

        <td width="33%"><input id="TeamLeaderName" name="TeamLeaderName" type="text" size="20%" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $TeamLeaderName; ?>" size="8" tabindex="1"></td>

        </tr>

        <td width="33%"><label class="desc" id="Notes" for="Notes">Notes : </label></td>

        <td width="33%"><textarea id="Notes" name="Notes" class="field text fn" style="background-color:#FCF5D8;color:black;" value="<?php echo $Notes; ?>" size="8" tabindex="1"></textarea></td>

        </tr>

        </table>

        </td>

        </tr>

        </table>

       

       

      </form>

      </div>

       

               

      </div>

        </div><br><br>

       

        <div id="exTab1" class="container">

      <ul  class="nav nav-pills">

        <li class="active">

        <input name="save" type="submit" value="Save"/>

        </li>

        </ul>

       

       

        <br>

        </div>

       

       

       

       

      <hr></hr>

       

       

       

       

       

       

      <!-- Bootstrap core JavaScript

          ================================================== -->

        <!-- Placed at the end of the document so the pages load faster -->

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

        <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

       

       

              </div>

              <!-- /.container -->

       

       

          </div>

          <!-- /.intro-header --> 

       

           <?php

        include 'footer.php';

        ?>

       

       

          <!-- jQuery -->

          <script src="js/jquery.js"></script>

       

       

          <!-- Bootstrap Core JavaScript -->

          <script src="js/bootstrap.min.js"></script>

       

       

      </body>

       

       

      </html>