The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
![]() |
getting fields from the database into a form - 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 fields from the database into a form (/showthread.php?tid=898) Pages:
1
2
|
getting fields from the database into a form - Printline - Oct 26th, 2010 Hi' there I'm trying to do a setup where i want to get some information from the database into a specific form automatically. Here is my setup: I want a user to register in order to get access to the form. I believe i can use the submission accounts module in order to achieve this. Then i will use the Extended Client Fields to add some additional fields to client account which the client must fill in. In may case it is Address, zip, city etc. Now, when he fills in the form he has gained access to, in this case it is ordering some products, he reaches a page that's named delivery. Here instead of filling in the address information, i was wondering if i can set it up, so that this information is filled out automatically, with the information from the database that the client filled in earlier. This would be the extra fields i created from the extended client fields module. Thanks in advance for any answers to my problem! RE: getting fields from the database into a form - Ben - Oct 26th, 2010 Hey Printline, Thanks for the post! Interesting problem! Well, if you were able to get the client ID (which is unique) on the delivery page, you could use a Core function to pull all the information about that client (I can provide instructions on how to do that when the time comes). However, even this would be fiddly: you'd need to extract the information on the first time you got to the page to pre-load the fields; but for subsequent visits (assuming the person will return to the page) it would have to pull from the form itself. Hmm... you'll definitely need a programmer around to suss out the details. Sorry! I don't have a simple, concrete solution for you. ![]() - Ben RE: getting fields from the database into a form - Printline - Oct 27th, 2010 Hi' Ben Thanks for the quick response. I would really appreciate, if you could get me started on how to grab the unique client ID and pull the information to be displayed in the form. I do have some PHP programming knowledge. The user will make subsequent visits to the form. - Printline RE: getting fields from the database into a form - Ben - Oct 28th, 2010 Hey Printline, Sure, no problem! The first step is to sort out this bit: "Now, when he fills in the form he has gained access to...". How is he gaining access to that form, exactly? Is the user logging into Form Tools then redirecting to a form on your server or something? Or will the form only be within Form Tools? - Ben RE: getting fields from the database into a form - Printline - Oct 29th, 2010 (Oct 28th, 2010, 5:35 PM)Ben Wrote: Hey Printline, Hey Ben Again, thanks for the quick response. My setup is as follows: The user log in to form tools as a client. He then clicks a link, which takes him to the form to fill out. He can then afterwards see what he filled in through form tools. He doesn't fill out the form from within form tools, and i have set it up, so that he can't even edit the form from within form tools. Form tools and the form in question is on the same server, and if nesecessary, can even be placed in the same directory, if this makes it easier or have any influence on how to accomplish what i want. RE: getting fields from the database into a form - Printline - Nov 9th, 2010 (Oct 29th, 2010, 5:46 AM)Printline Wrote:(Oct 28th, 2010, 5:35 PM)Ben Wrote: Hey Printline, Hi Ben Any news/progress on how to get me started on the above...??? Thanks! RE: getting fields from the database into a form - Ben - Nov 9th, 2010 Hi Printline, Sorry! There's always a million things to do around here! ![]() Cool, so since the user just logged in, information about their account is in sessions. 1. On your form page, make sure that sessions have been started. (session_start()). 2. As a test, add this line to your form somewhere: PHP Code: Client ID: <?php echo $_SESSION["ft"]["account"]["account_id"]; ?> If everything is working, it should output the client ID. If it does, just delete it. 3. Next, we're going to use that ID to get all the client info: PHP Code: <?php You can then use that information to populate your form. Any help at all? - Ben RE: getting fields from the database into a form - Printline - Nov 10th, 2010 (Nov 9th, 2010, 9:08 PM)Ben Wrote: Hi Printline, Hi' Ben Thanks for the response. It actually works great! One thing though, that troubles me a bit is this: I got it working by doing the following: I set the php code like this: PHP Code: $account_info = ft_get_account_info($_SESSION["ft"]["account"]["account_id"]); And then display the information in the form in a textbox like this: <input type="text" name="firstname" value="<?php echo $emailaddress; ?>" /> <input type="text" name="email" value="<?php echo $name; ?>" /> The issue is now, that i want to retrieve some informaton from additional fields from the account, which i have made by using the Extended Client Fields module. As far as i can see these data are being placed in another location. When i do the print_r function i get this: Code: Array ( [account_id] => 2 [account_type] => client etc... Code: Array ( [account_id] => 2 [account_type] => client etc..[settings] => Array ( [client_notes] => [company_name] => Printline [ecf_1] => 12345678 [ecf_2] => Nordbirkvej 4 etc... Can you tell me how i can retrieve and show these information also....??? Thanks a lot! Printline RE: getting fields from the database into a form - Ben - Nov 12th, 2010 Excellent! Sounds like you've made a lot of progress. If I understand you right, that additional info is just stored in a subarray? I think that's the way it works... Could you do this? PHP Code: $ecf_1 = $account_info["settings"]["ecf_1"]; And then stash that value in your form field? - Ben RE: getting fields from the database into a form - Printline - Nov 15th, 2010 (Nov 12th, 2010, 11:11 AM)Ben Wrote: Excellent! Sounds like you've made a lot of progress. Hi Ben Damn... Of course it is a subarray, why didn't i see that....??? Now it works perfect. Thanks a lot. Now, i want to do the exact same thing when a user wants to edit a submitted form. I know that i can set it up in form tools, so that a user can edit their submissions directly from within formtools. But i want to fetch the data and put it in the form automatically because i do som price calculation from within the form. So i added a link from within the edit_sbmission page in formtools to my form, and then added this code to my form. PHP Code: $form_info = ft_get_form_info($_SESSION["ft"]["form"]["form_id"]); and thought that this would work like when fetching the account info, but i get the following error: Quote:Call to undefined function: ft_get_form_info() Am i way of track here, or is this possible at all....????? |