【发布时间】:2015-11-19 20:18:34
【问题描述】:
我正在尝试在单击按钮时从文本字段中检索信息并将数据发送到 mail@example.com:
$(document).ready(function() {
$("#submit").click(function() {
var email = $("#email").val();
var name = $("#Name").val();
var subject = $("#Subject").val();
var text = $("#textarea").val();
var telephone = $("#tel").val();
var varData = "email : " + email + "name : " + name + "subject : " + subject + "text : " + text + "telephone : " + telephone;
console.log(varData);
$.ajax({
type: "POST",
url: 'sendPHP.php',
data: varData,
success: function() {
alert("message sent");
}
});
});
});
sendPHP.php:
<?php
$to = 'mail@example.com';
$name = $_POST['email'];
and so on ..
..
..
mail(mail@example.com, name, (here goes email, name, subject, textarea, tel) as message in new lines);
and somewhere i have to write from what emial im sending to example@gmail.com and what is it's password i guess
?>
【问题讨论】:
-
您的问题/问题到底是什么?
-
我的问题是我不知道语法以及我应该在哪里将文件与 php 代码链接。我真的很新我知道我必须首先阅读语法只是想要一个快速帮助它的项目只需要这个 php 代码
-
mail()函数的语法? -
哥们,在问题区问一个明确的问题,而不是在 cmets。
标签: javascript php jquery ajax email