我设法成功收到了电子邮件。但在我收到的电子邮件中是空白的。收到的输入值名称数据中没有一个单词。
$('#ajax').on('submit',function(){
var that = $(this),
url = that.attr('action'),
type = that.attr('method'),
data = [];
that.find('[name]').each(function(index, value){
var that = $(this),
name = that.attr('name'),
value = that.val();
data[name] = value;
});
$.ajax({
url: url,
type: type,
data: data,
dataType: "script",
success: function(){
console.log();
}
});
return false;
});
PHP
<?
php
$fname = $_POST["custfirstname"];
$lname = $_POST["custlastname"];
$cemail = $_POST["custemail"];
$contact = $_POST["custcontact"];
$msg = $_POST["custmsg"];
$to = "anikorekushon@gmail.com";
$subject = "AniKoReKuShon Purchasing Form";
$message = $fname . ' ' . $lname . ' ('. $contact . ')';
$message = $cemail;
$message = $custmsg;
mail($to,$subject,$message);
?>
有什么问题?
答案 0 :(得分:0)
您需要按如下方式连接数据。确保所有数据都以PHP格式提供
$message = '';
$message .= $fname . ' ' . $lname . ' ('. $contact . ')';
$message .= $cemail;
$message .= $custmsg;
答案 1 :(得分:0)
感谢大家的帮助。尝试但仍未解决。直到我添加if($ _ POST){#code ...}。内部和管理数据发送到我的电子邮件。
<?php
if($_POST){
$fname = $_POST["custfirstname"];
$lname = $_POST["custlastname"];
$cemail = $_POST["custemail"];
$contact = $_POST["custcontact"];
$msg = $_POST["custmsg"];
$to = "anikorekushon@gmail.com";
$subject = "AniKoReKuShon Purchasing Form";
$message = $fname . ' ' . $lname . ' ('. $contact . ')';
$message .= $cemail;
$message .= $custmsg;
mail($to,$subject,$message);
}
?>