Forums

[SOLVED] Thanks message php code?

SubCon 08 Jan, 2012
Hello, I need some more info to finish my chronoform code:

I need to show some info in "Thanks Message". The info is taken from DB. The "Thanks Message" code does not allow php there, so I figure I maybe able to run the code at onsubmit event, but how do I transfer the variables to the "Thanks Message" code?

Also similar issue is with email template, there also some info that I get from DB needed to be shown, I'm guessing it should be the same technic..

Thanks
GreyHead 08 Jan, 2012
Hi SubCon,

Is this ChronoForms v4?

If so then you can use a DB Record Loader action (or actions) to get data from the database and add it to the Form data array; then you can use the curl_bracket syntax in the Show Thanks Message action e.g. {param_name}.

Bob
SubCon 08 Jan, 2012
Thanks Bob, yes it v4 and the info is from sobi2 not from chronoform tables although I'm not familiar with "DB Record Loader" maybe it can do that, I'll have to look it up ))
Anyway I understand the logic, now I'll see if I can implement it,
Thanks again.
SubCon 08 Jan, 2012
Ok got it working, I'll post my code here so that if anyone would understand from example.

I edit my form in wizard "(Edit in Advanced Mode)", so there I'll goto code->"Custom Code - Before Email(s)" and there goes my php.


<?php
$db =& JFactory::getDBO();				
	$session =& JFactory::getSession();		
	$cc_ids_arr = $session->get('sobisend'); //get id's array from session (sobi2 item id's)
foreach ($cc_ids_arr as $m_id) {
	$query = "SELECT * FROM `#__sobi2_item` WHERE `itemid`='$m_id'";
	$db->setQuery($query);
	$row = $db->loadAssoc();
        $movilim .= "<li>".$row['title']."</li>"; //set item titles variable and format into html.
}
$form->data['ttls'] = $movilim; //set the form array
?>


So now in my "Thanks message" and email templates I can use "{ttls}".
If the php code would go into "Custom Code - After Email(s)", you can still get the {ttls}
in "Thanks message" but the emails already sent so for email templates it will not work.
This topic is locked and no more replies can be posted.