Hi,
I've created a form with a response mail and a data storage in the db. This mail contains fields that the user has filled in. Now i want to add a 'database' field like the cf_id to the mail. This field is not on the form. I hope it makes sense, is this possibele and how?
Regards,
Wes
I've created a form with a response mail and a data storage in the db. This mail contains fields that the user has filled in. Now i want to add a 'database' field like the cf_id to the mail. This field is not on the form. I hope it makes sense, is this possibele and how?
Regards,
Wes
Hi wes,
This is a bit tricky as the Email is sent before the Database is updated.
There are a couple of ways round:
a) Use the OnSubmit After code box to add the code to send an email and use the ChronoForms variable $row_jos_table_name to access the info:
b) Create a random ID in your Form HTML and add this to both the email and the database.
Both routes have advantages and disadvantages. I prefer the second mainly because there are some security risks in using serial numbers - e.g. 99, 100, 100 - to identify records as it's easy to guess and test what other ids are.
Bob
This is a bit tricky as the Email is sent before the Database is updated.
There are a couple of ways round:
a) Use the OnSubmit After code box to add the code to send an email and use the ChronoForms variable $row_jos_table_name to access the info:
<?php
global $row_jos_table_name;
$cf_id = $row_jos_table_name['cf_id'];
. . .
b) Create a random ID in your Form HTML and add this to both the email and the database.
Both routes have advantages and disadvantages. I prefer the second mainly because there are some security risks in using serial numbers - e.g. 99, 100, 100 - to identify records as it's easy to guess and test what other ids are.
Bob
Hi Bob,
Thanks again. The problem is it can't be a random number because there may be no gap between the numbering (e.g. 2009001, 2009002, 2009003 etc). I was thinking of adding an extra column to the database with this info.
Why in the after code box? I want it to be directly in the mail which is formatted at tab Email templates. Is the caption also {cf_id} or is it something else?
In ChronoForms there is an option Saving/Data emails order can this be an solution?
Regards,
Wes
Thanks again. The problem is it can't be a random number because there may be no gap between the numbering (e.g. 2009001, 2009002, 2009003 etc). I was thinking of adding an extra column to the database with this info.
Why in the after code box? I want it to be directly in the mail which is formatted at tab Email templates. Is the caption also {cf_id} or is it something else?
In ChronoForms there is an option Saving/Data emails order can this be an solution?
Regards,
Wes
Hi wes,
You can add an extra column to the database and make it auto-increment. That's fine.
The problem is knowing what the next id is at the time you send the email. If - for argument's sake - there are three different people completing the form at the same time there is no way of knowing which one will get saved first.
So to handle that you need to send the email *after* the data is saved to the database when you know for sure what the id is.
Bob
You can add an extra column to the database and make it auto-increment. That's fine.
The problem is knowing what the next id is at the time you send the email. If - for argument's sake - there are three different people completing the form at the same time there is no way of knowing which one will get saved first.
So to handle that you need to send the email *after* the data is saved to the database when you know for sure what the id is.
Bob
This topic is locked and no more replies can be posted.