Running: Modx Evolution 1.0.5
I've been working to get eForm to send the entered form data to two email address, while also saving it to a database table in the current modx database. I have it sending to the two email addresses fine, but I'm having trouble getting it to save to the database in addition to that. I'm a novice at database stuff, so I'm hoping I'm just missing something easy.
I've pretty much based it all off of this guide in the wiki:
http://wiki.modxcms.com/index.php/Use_eForm_to_Store_data_into_Database
Here is the eForm snippet call plus the call to the save to database snippet:
[!contactDatabaseSave!]
[!eForm? &formid=`feedbackForm` &to=`[email protected],[email protected]` &tpl=`eFeedBackForm` &report=`eFeedbackReport` &thankyou=`eFeedBackThanks` &mailselector=`department` &vericode=`0` &subject=`Web site feedback` &eFormOnBeforeMailSent=`contactDatabaseSave`!]
Here is the save to database snippet:
<?php
function agregarCargas( &$fields )
{
global $modx;
// Init our array
$dbTable = array();
$dbTable['name'] = $modx->db->escape($fields['name']);
$dbTable['email'] = $modx->db->escape($fields['email']);
$dbTable['fax'] = $modx->db->escape($fields['fax']);
$dbTable['phone'] = $modx->db->escape($fields['phone']);
$dbTable['address'] = $modx->db->escape($fields['address']);
$dbTable['address2'] = $modx->db->escape($fields['address2']);
$dbTable['city'] = $modx->db->escape($fields['city']);
$dbTable['state'] = $modx->db->escape($fields['state']);
$dbTable['zip'] = $modx->db->escape($fields['zip']);
$dbTable['Country'] = $modx->db->escape($fields['Country']);
$dbTable['Patient'] = $modx->db->escape($fields['Patient']);
$dbTable['heard'] = $modx->db->escape($fields['heard']);
$dbTable['procedure'] = $modx->db->escape($fields['procedure']);
$dbTable['comments'] = $modx->db->escape($fields['comments']);
// Run the db insert query
$dbQuery = $modx->db->insert($dbTable, 'form_data' );
return true;
}
?>
When I attempt to send the form with these things in place, I just get a server error:
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
I appreciate any help!
[ed. note: firebot6 last edited this post 12 years, 2 months ago.]