$query = "INSERT INTO `{$diy->table}` (`id`, `ifcheck` $addvar) VALUES (NULL, 0 $addvalue); ";
引入phpmailer
添加以下代码:
-
-
$addvalue_ary = explode(',', $addvalue);
-
-
$addvar_ary = array(
-
1 => '称呼',
-
2 => 'Email',
-
3 => '手机/电话',
-
4 => '网站',
-
5 => '留言内容',
-
);
-
-
$text = '';
-
foreach($addvar_ary as $key=>$value)
-
{
-
$text.=$value.': '.$addvalue_ary[$key].'<br>';
-
}
-
-
require("class.smtp.php");
-
require("class.phpmailer.php");
-
-
$mail = new PHPMailer();
-
$mail->CharSet = "utf-8";
-
$mail->Encoding = "base64";
-
$mail->WordWrap = 50;
-
$mail->IsHTML(true);
-
$mail->IsSMTP();
-
$mail->Host = "smtp.163.com";
-
$mail->FromName="新官网留言";
-
$mail->SMTPAuth = true;
-
$mail->Username = "XXXX@163.com";
-
$mail->Password = "XXXXXXX";
-
$mail->Port=25;
-
$mail->From = "XXXX@163.com";
-
$address ="XXXX@XXX.cn";
-
$mail->AddAddress($address, "XXX");
-
-
-
if($action == 'post') {
-
-
if($do == 2) {
-
-
$mail_title="客户留言".date('y-m-d H:i:s',time());
-
$mail->Subject = $mail_title;
-
$mail->Body = $text;
-
-
if(!$mail->send())
-
{
-
-
showMsg('发送失败', 'javascript:;');
-
-
exit;
-
}
-
-
-
}
-
}
-
-
if($dsql->ExecuteNoneQuery($query))
-
{
-
$id = $dsql->GetLastID();
-
if($diy->public == 2)
-
{
-
-
$goto = "diy.php?action=list&diyid={$diy->diyid}";
-
$bkmsg = '发布成功,现在转向表单列表页...';
-
}
-
else
-
{
-
$goto = '-1';
-
$bkmsg = '邮件已经自动发送到SPARK工作人员,请等待联系您!';
-
}
-
echo "OK";
-
-
}
-
}
-
}
JS代码:
-
var dataString = 'iname='+ $("#name").val() + '&email=' + $("#email").val() + '&tel=' + $("#tel").val()+ '&website=' + $("#website").val()+ '&action=post'+ '&diyid=1&do=2&dede_fields=iname,text;email,text;tel,text;website,text;content,text&dede_fieldshash=1f6d061a5dd65989abfd887';
-
$.ajax({
-
type: "POST",
-
url: "/plus/diy.php",
-
data: dataString,
-
success: function(data) {
-
if(data=="OK"){
-
-
$("#submitmask").fadeOut(500);
-
alert("提交成功!");
-
}else{
-
$("#submitmask").fadeOut(500);
-
alert("出错了!请使用其他方式联系我们!");
-
}
-
}
-
});
-
return false;