After developing an input form in part 3, we of course need to know how to process the submitted data.

You probably don't find anything in Facebook documentation on how to process the submitted data from a FBML form. The answer is simple: the submitted data is nothing special and specific to Facebook. As a result, we simply process the data as is how we process the data from a HTML form.

 

Processing the Submitted Data

As an example, the following page will process the submitted data by simply displaying the data on screen.

<?php

  require_once 'lib/facebook.php';
  require_once 'config.php';

  $facebook = new Facebook($appapikey, $appsecret);
  $user_id = $facebook->require_login("publish_stream");

  include 'dashboard.php';
  include 'tabs.php';
  if (isset($_REQUEST['fbuid'])) {
       $fbuid = html_entity_decode( $_REQUEST['fbuid'], ENT_QUOTES);
       echo "<p><fb:name uid=\"$fbuid\" useyou=\"false\" />, thank you for submitting the form!</p>";
       } else {
       echo "<p>Error in processing form data!</p>";
  }

  for ($i = 1; $i <=7; $i += 1) {
    if (isset($_REQUEST['field' . $i])) {
      $data = html_entity_decode( $_REQUEST['field' . $i], ENT_QUOTES);
      echo "<p>Field $i Data: $data</p>";
    }
  }

  if (isset($_REQUEST['field2_day'])) {
    $field2_day = htmlentities( $_REQUEST['field2_day'], ENT_QUOTES);
    if (isset($_REQUEST['field2_month'])) {
      $field2_month = html_entity_decode( $_REQUEST['field2_month'], ENT_QUOTES);
    }
    echo "<p>Field 2 Data: $field2_day / $field2_month</p>";
  }

?>    

Sample screen showing the processed data is shown below:

 

Database Access

You can try to save the extracted data to a database! The processing is the same as writing ordinary PHP code for performing database access.