This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 3
Add form data to second database
Started 12 years ago by ROYW1000 | 3 posts |
-
Hi
Is it possible when someone completes a form that machform stores it as usual but some of the elements are transferred to a different database with different column names.
If this is possible can you supply some code and let me know where to put it.
Thanks in advance
Roy
Posted 12 years ago # -
Hi
Does anyone know if this is possible?
Also has anyone ever attached a HTML Editor to the form?
Thanks
RoyPosted 12 years ago # -
Hi Roy,
It is possible to do this, but you will need to know some PHP to be familiar with the modifications.
The easiest way to do this is to add privileges to your current machform mysql user to be able accessing the other database.
So that the mysql user is having permission to access your machform database and the other database.Once the privileges being set, you can edit your "includes/post-functions.php" file. Search around line 2393 for this code:
if($process_result['status'] === true){
right exactly below that line, you can add the custom code to do the insert into another database. The code would be something like this:
mf_do_query("use myotherdb",array(),$dbh); $query = "insert into test_table(mytext) values(?)"; $params = array($table_data['element_1']); mf_do_query($query,$params,$dbh);
in the above sample code, the other database name is "myotherdb" and the table name is "test_table".
All your form data is available through $table_data variable, which is an array.MachForm Founder
Posted 12 years ago #
Reply
You must log in to post.