My snippet code is
function downloadForm( &$fields )
{
global $modx;
$email=$fields[emailaddress];
$sql = ("select * from `emp_download_form` where `emailaddress` = ’".$fields[’emailaddress’]."’");
$rs = $modx->db->query($sql);
$limit = mysql_num_rows($rs);
if ($limit > 0) {
$header = "Location: index.php?id=6&msg=Email already exit";
header($header);
return true;
}
else{
$date=date(’Y-m-d’);
$dbTable = array();
$dbTable[firstname] = $fields[firstname];
$dbTable[lastname] = $fields[lastname];
$dbTable[emailaddress] = $fields[emailaddress];
$dbTable[contactno] = $fields[contactno];
$dbTable[jobtitle] = $fields[jobtitle];
$dbTable[companyname] = $fields[companyname];
$dbTable[industry] = $fields[industry];
$dbTable[country] = $fields[country1];
$dbTable[city] = $fields[city];
$dbTable[state] = $fields[state];
$dbTable[city] = $fields[city];
$dbTable[pincode] = $fields[pincode];
$dbTable[noofemp] = $fields[noofemployee];
$dbTable[comments] = $fields[comments];
$dbTable[address1] = $fields[address1];
$dbTable[address2] = $fields[address2];
$dbTable[date] =$date;
// Run the db insert query
$dbQuery = $modx->db->insert($dbTable, ’emp_download_form’);
}
$header = "Location: index.php?id=16";
header($header);
return true;
}
if($_GET[msg])
echo "<font color=’#FF0000’>Email Already Exists. Please Try with another Email Address.</font>";
if($_GET[msg1])
echo "<font color=’#FF0000’>Please fill the form with alternate email address</font>";
?>
I call snippet like this
[!downloadForm!][!eForm? &to=’[+emailaddress+],
[email protected]’ &formid=`downloadForm` &eFormOnBeforeMailSent=`downloadForm` &tpl=`downloadForm` &report=`downloadFormReport_latest` &subject=`Activation mail` &cc=`1`!]
Thanks