The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
Getting Data From database - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1)
+--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5)
+--- Thread: Getting Data From database (/showthread.php?tid=1578)



Getting Data From database - DrkNT - Aug 31st, 2011

Hi,

I'm trying to get the forms data from the database and show it in a custom page which is similar to Edit submission page that is already available in FormTools.

I manage to figure out how to pass the client info to my page using the codes below which i found from other threads.

PHP Code:
$account_info ft_get_account_info($_SESSION["ft"]["account"]["account_id"]);
$emailaddress = ($account_info['email']);
$client_first_name =($account_info['first_name']);
$client_last_name =($account_info['last_name']);
$client_store = ($account_info["settings"]["ecf_1"]);
$client_store_type = ($account_info["settings"]["ecf_2"]); 

But, I cannot figure out how to pull the data from the database and insert each value into the fields like you did in edit submission.

I tried using ft_api_show_submissions api, but it just shows all the data I had in the database.

I have also seen the registration demo's code. However I think this method only works in multi-page form?

Is there a function or variable that I can use like $_SESSION?

Basically, what I'm trying to do is to make a custom edit submission page that also have the client's info stored in the database.


RE: Getting Data From database - Ben - Sep 4th, 2011

Hi DrkNT,

Interesting! Hmm... to be honest it isn't really something I can just explain in a few lines. There's a great deal going on in the Form Tools edit submission page with displaying and editing the content.

But maybe check out the Submission Accounts module. That has it's own Edit Submission page that's a little less complicated than the one in the Core (but still pretty complicated, sorry!). Hopefully it will be a little easier to make sense of the code of how it's all fitting together.

Sorry, I wish I could be more help but this is very much a hands-on thing that requires a lot of digging through code.

- Ben



RE: Getting Data From database - DrkNT - Sep 4th, 2011

Hi Ben,
I understand that after all the checks that edit_submission.tpl does, it will display the data using smarty code:

Code:
{edit_custom_field form_id=$form_id submission_id=$submission_id field_info=$curr_field field_types=$field_types settings=$settings} {$settings}

However I cannot figure out how it is showing the data. From what I understand of how FormTools works is that it needs the form_id and submission_id to know which table from the database to open.

I just need to know how to get it out of the array.

Thank you.

Edit:
Nvm, I Figured it out. I can use the code below to get the data I need.
Code:
$Data = ft_get_submission($_GET[form_id],$_GET[submission_id]);
echo $Data[1]['content'];

I Just hope that the Edit portion will be correct


RE: Getting Data From database - DrkNT - Sep 11th, 2011

Hi Ben,

I Manage to link the data to my page and I found the codes needed to submit the updated form.

Code:
$editable_field_ids = _ft_get_editable_view_fields($view_id);
if (isset($_POST) && !empty($_POST))
{
  // add the view ID to the request hash, for use by the ft_update_submission function
  $request["view_id"] = $view_id;
  $request["editable_field_ids"] = $editable_field_ids;
  $request["context"] = "submission_accounts";
  list($g_success, $g_message) = ft_update_submission($form_id, $submission_id, $request);
  // required. The reason being, this setting determines whether the submission IDs in the current form-view-search
  // are cached. Any time the data changes, the submission may then belong to different Views, so we need to re-cache it
  $_SESSION["ft"]["new_search"] = "yes";
  var_dump(  $g_message);
}

The return I get from $g_success is true and everything seems to be working properly. However the real data in the database is not updated.

Did I miss something? What else is needed to update the data from the form?

Also I tried to use Submission account module, but it did not show the editable fields after the user is logged in. Is this a bug?


RE: Getting Data From database - aningbo - Sep 11th, 2011

Submission account module has been updated. it was a bug which has been fixed in the latest version. update it.


RE: Getting Data From database - DrkNT - Sep 13th, 2011

(Sep 11th, 2011, 10:39 PM)aningbo Wrote: Submission account module has been updated. it was a bug which has been fixed in the latest version. update it.

Thank you aningbo, it works now.


Ok, after much testing I realise that the $editable_field_ids variable can get the field id list but it is not transferred and stored into $request["editable_field_ids"] somehow the data is lost once I click on submit.

Any idea how to resolve this problem?