Posts: 17
Threads: 6
Joined: Oct 2010
Reputation:
0
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!
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
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
Posts: 17
Threads: 6
Joined: Oct 2010
Reputation:
0
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
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
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
Posts: 17
Threads: 6
Joined: Oct 2010
Reputation:
0
(Oct 28th, 2010, 5:35 PM)Ben Wrote: 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
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.
Posts: 17
Threads: 6
Joined: Oct 2010
Reputation:
0
(Oct 29th, 2010, 5:46 AM)Printline Wrote: (Oct 28th, 2010, 5:35 PM)Ben Wrote: 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
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.
Hi Ben
Any news/progress on how to get me started on the above...???
Thanks!
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
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 $account_info = ft_get_account_info($_SESSION["ft"]["account"]["account_id"]); print_r($account_info); ?>
You can then use that information to populate your form.
Any help at all?
- Ben
Posts: 17
Threads: 6
Joined: Oct 2010
Reputation:
0
(Nov 9th, 2010, 9:08 PM)Ben Wrote: 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 $account_info = ft_get_account_info($_SESSION["ft"]["account"]["account_id"]); print_r($account_info); ?>
You can then use that information to populate your form.
Any help at all?
- Ben
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"]); $emailaddresse = ($account_info['email']); $name =($account_info['first_name']);
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...
When it then comes to displaying values from the other fields it does it like this:
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
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
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
Posts: 17
Threads: 6
Joined: Oct 2010
Reputation:
0
(Nov 12th, 2010, 11:11 AM)Ben Wrote: 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
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"]); print_r($form_info);
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....?????
|