Posts: 8
Threads: 2
Joined: Dec 2011
Reputation:
0
Hi everyone,
My website has grown somewhat since i started using Form Tools and the more i use it the more fantastic ideas i come up with.
A year down the track and i'm happily using the data in ways i never imagined (probably childs play for some of you programmers but i'm a humble carpet cleaner).
So here is my problem - I think the answer is i cant do it this way but maybe someone out there has a suggestion.
I wrote some php code to add a record in mysql . The record is normally added with a 'post' form submission to a database in formtools where it trickers an email, a mobile text message to the client and redirects the webpage to somewhere suitable.
The problem is when adding a record with php i'm not getting the email or text message. I'm guessing its because the record isnt being submitted as a form post but does anyone have any ideas as to how i can get formtools to send the email and text this way?
Thanks
Rob
Posts: 8
Threads: 2
Joined: Dec 2011
Reputation:
0
Dec 5th, 2011, 1:55 PM
(This post was last modified: Dec 5th, 2011, 1:55 PM by carpetman.)
ok i downloaded some script but it didnt work grrrr
so i'm going to try and set up a hidden form to see if this works - it will duplicate the existing form on the same page but php will replace the first one with the hidden one when needed. The idea is the user clicks the button without seeing the sensitive data behind it.
I'll keep you posted but if someone else has a better idea i'd be happy to hear it.
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Dec 6th, 2011, 10:35 AM
(This post was last modified: Dec 6th, 2011, 10:35 AM by Ben.)
Hi Carpetman,
Cool! No problem, here's how you can trigger it manually.
The emails are "normally" triggered in the ft_finalize_submission() function, called when the submission is finally marked as complete & ready to show up in the interface. But in your case, you can just call the email function manually. Here's some example code:
PHP Code: // your insert code here mysql_query(" ... ");
// get the unique Submission ID that you just inserted $submission_id = mysql_insert_id();
// now send whatever emails are associated with this event ("on submission") for this form $form_id = 1; // you'll need to update this for your own form ID ft_send_emails("on_submission", $form_id, $submission_id);
Hope this helps!
- Ben
Posts: 8
Threads: 2
Joined: Dec 2011
Reputation:
0
(Dec 6th, 2011, 10:35 AM)Ben Wrote: Hi Carpetman,
Cool! No problem, here's how you can trigger it manually.
The emails are "normally" triggered in the ft_finalize_submission() function, called when the submission is finally marked as complete & ready to show up in the interface. But in your case, you can just call the email function manually. Here's some example code:
PHP Code: // your insert code here mysql_query(" ... ");
// get the unique Submission ID that you just inserted $submission_id = mysql_insert_id();
// now send whatever emails are associated with this event ("on submission") for this form $form_id = 1; // you'll need to update this for your own form ID ft_send_emails("on_submission", $form_id, $submission_id);
Hope this helps! 
- Ben
OMG You are a genious!! Many thanks - i have many other uses for this so it's going to be a late night in front of the computer
I'm guessing the ft_send_emails("on_submission", $form_id, $submission_id); is caling the function so i need to declare it before? and i'm guessing the function is somewhere in my formtools directory.
I'll give it a go and tell you how it works.
Once again, many thanks for this.
Posts: 8
Threads: 2
Joined: Dec 2011
Reputation:
0
Dec 9th, 2011, 10:16 AM
(This post was last modified: Dec 9th, 2011, 10:46 AM by carpetman.)
(Dec 6th, 2011, 10:35 AM)Ben Wrote: Hi Carpetman,
Cool! No problem, here's how you can trigger it manually.
The emails are "normally" triggered in the ft_finalize_submission() function, called when the submission is finally marked as complete & ready to show up in the interface. But in your case, you can just call the email function manually. Here's some example code:
PHP Code: // your insert code here mysql_query(" ... ");
// get the unique Submission ID that you just inserted $submission_id = mysql_insert_id();
// now send whatever emails are associated with this event ("on submission") for this form $form_id = 1; // you'll need to update this for your own form ID ft_send_emails("on_submission", $form_id, $submission_id);
Hope this helps! 
- Ben
Hi Ben,
I added this to a test page:
include("formtools/global/code/emails.php");
include("formtools/global/code/hooks.php");
include("formtools/global/code/fields.php");
ft_process_email_template('1','1007','23');
and i'm getting this errror:
Access denied for user 'carpetc7'@'localhost' (using password: NO)
Any chance of putting me in the right direction? I'm guessing the formtools code is querying mysql and doesnt have the password because i havent logged in.
Thanks
Rob
Oops - forget that - i know what i'm missing. I am getting error after error but i'm working through them. I may need a bit of help if i get stuck though 
ok i got this error now
Table 'carpetc7_formtools.form_fields' doesn't exist
i checked mysql and i have table ft_form_fields but its looking for form_fields
any ideas
Posts: 8
Threads: 2
Joined: Dec 2011
Reputation:
0
ok i got it - it needs the library
include("formtools/global/library.php");
$form_id=1;
$submission_id=1016;
$email_id=1;
ft_process_email_template($form_id, $submission_id, $email_id);
cool - now i can set the form , email and submission variables as needed in my code.
Thanks Ben
Posts: 4
Threads: 2
Joined: Jun 2013
Reputation:
0
(Dec 10th, 2011, 9:37 AM)carpetman Wrote: ok i got it - it needs the library
include("formtools/global/library.php");
$form_id=1;
$submission_id=1016;
$email_id=1;
ft_process_email_template($form_id, $submission_id, $email_id);
cool - now i can set the form , email and submission variables as needed in my code.
Thanks Ben
You all are genius, this is exactly what I needed.
Thanks!!
|