$aForm = array(
'form_attrs' => array(
'name' => 'form_Contact',
'method' => 'post',
),
'params' => array (
'db' => array(
'table' => 'sys_messages', // table name
'key' => 'ID', // key field name
'uri' => '', // uri field name
'uri_title' => '', // title field to generate uri from
'submit_name' => 'submit_contact_form', // some filed name with non empty value to determine if the for was submitted,
// in most cases it is submit button name
),
'csrf' => array(
'disable' => true, //if it wasn't set or has some other value then CSRF checking is enabled for current form, take a look at sys_security_form_token_enable to disable CSRF checking completely.
)
),
'inputs' => array(
'header1' => array(
'type' => 'hidden',
),
'Name' => array(
'type' => 'text',
'name' => 'Subject',
'db' => array (
'pass' => 'Xss',
),
'caption' => _t("Name"),
'checker' => array (
'func' => 'length',
'params' => array(3, 256),
'error' => _t('_sys_adm_form_err_required_field'),
),
),
'Email' => array(
'type' => 'text',
'name' => 'Email',
'db' => array (
'pass' => 'Xss',
),
'caption' => _t("Email"),
'checker' => array (
'func' => 'length',
'params' => array(3, 256),
'error' => _t('_sys_adm_form_err_required_field'),
),
),
'Phone' => array(
'type' => 'text',
'name' => 'Phone',
'db' => array (
'pass' => 'Xss',
),
'caption' => _t("Phone Number"),
),
'Message' => array(
'type' => 'textarea',
'name' => 'Text',
'db' => array (
'pass' => 'Xss',
),
'caption' => _t("Message"),
),
'Captcha' => array(
'type' => 'slider',
'name' => 'replace_captcha',
'caption' => _t("Slide to Right"),
'checker' => array (
'func' => 'length',
'params' => array(3, 3),
'error' => _t('Please slide to the right to verify you are human'),
),
),
'header1_end' => array(
'type' => 'block_end'
),
'submit_send' => array(
'type' => 'submit',
'colspan' => true,
'name' => 'submit_contact_form',
'value' => _t("Send"),
),
),
);
$oForm = new BxTemplFormView ($aForm);
$oForm->initChecker();
if ($oForm->isSubmittedAndValid ()) {
$profileID = getID( $_GET['ID'] );
// add additional vars to database, in this case creation date field is added
$aValsAdd = array (
'sender' => $_COOKIE['memberID'],
'recipient' => $profileID,
);
if ($oForm->insert ($aValsAdd)) {
$to = "myemail@gmail.com";
$subject = "New Contact at MTSDemo from " . $_POST['Subject'];
$body = "You have a new message awaiting. Please login to your account at <a href='http://mytherapysession.com/mtsdemo'>MTS Demo @ MyTherapySession</a>";
$from = $_POST['Email'];
$headers = "From: " . $from;
if (mail($to, $subject, $body, $headers)) {
$sStatusText = 'Message Successfully Sent. We will contact you soon, but will not leave a phone message.';
} else {
$sStatusText = 'Message Not Sent';
}
}
}
if($sStatusText)
$sStatusText = MsgBox(_t($sStatusText), 3);
return array($sStatusText . $oForm->getCode(), array(), array(), false);