我如何设法接收文本区域内用户的输入?以下是我更详细的意思:
https://i.stack.imgur.com/trG1E.gif
我的 JS 看起来像这样:
$('#sad').on('click', function() {
const sad = $('#sad').val();
const { value: text } = Swal.fire({
title:'<strong>Lass uns mehr erfahren</strong>',
input: 'textarea'
}).then(function() {
$.ajax({
type: "POST",
url: "feedback.php",//===PHP file name and directory====
data:{sad: sad},
success:function(data){
console.log(data);
//Success Message == 'Title', 'Message body', Last one leave as it is
Swal.fire({
icon: 'success',
title: "Danke!",
showConfirmButton: false,
timer: 3000
});
},
error:function(data){
//Error Message == 'Title', 'Message body', Last one leave as it is
Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'Something went wrong!'
})
}
});
if (text) {
$.ajax({
type: "POST",
url: "feedback.php",
data: {'text': text}
})
}
})
})
和我的 PHP:
$sad = $_POST['sad'];
$text = $_POST['text'];
elseif(isset( $_POST['sad'] )) {
$EmailFrom = "xxxxxxxx@gmail.com";
$Subject = "New Feedback";
$mailTo = "info@xxxxxxxx.me";
$txt = "Oh no, you got a new 'Sad' review".$text;
$headers = 'From: ' .$EmailFrom. "\r\n";
mail($mailTo, $Subject, $txt, $headers);
header("Location: https://xxxxxxxx.me/?mailsend");
}
我收到了 $txt 部分,但没有收到每封电子邮件的用户输入:“哦,不,你收到了一条新的‘悲伤’评论”
墨色风雨