0
當我收到從網上問答我一直在做的結果,
我接受所有的HTML標籤中的電子郵件,(從DIV #resultKeeper) 我期待將其刪除,但如何?如果有人能夠強調我,那將是美好的!
這是我收到的電子郵件:
From: name
Message: message
Results:
<div id=\"questionanswrs\"> Question 1 is true</div><div id=\"questionanswrs\"> Question 2 is false</div><div id=\"questionanswrs\"> Question 3 is true</div><div id=\"questionanswrs\"> Question 4 is false</div><div id=\"questionanswrs\"> Question 5 is false</div><div class=\"totalScore\"><br>Your total score is 2/5</div><div class=\"totalScoreok\"><br>CONGRATULATION, YOUR LEVEL IS A1.1</div>
這裏是jQuery的部分:
$(function() {
$('#quesForm').on('submit',function(e) {
e.preventDefault();
// I am fetching the form values you could get them by other selectors too
var uname = $("input[name=username]").val();
var uemail = $("input[name=email]").val();
var msg = $("textarea").val()
$.post('submit.php',{username:uname,email:uemail,message:msg,results:$('#resultKeeper').html(),subject:'Subject of your e-mail'},function(result){
// result variable contains your response text
// I guess you trying to update your response
// notice I have used html(result) as you have just used html()
$('#responseMessage').html(result);
});
// you dont require `return false`
// you have already did it using e.preventDefault();
});
});
和我的PHP:
<?php $name = $_POST['username'];
$email = $_POST['email'];
$message = $_POST['message'];
$results = $_POST['results'];
$formcontent="From: $name \n Message: $message \n Results: \n $results";
$recipient = "[email protected]";
$subject = "my subject";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Your email has been send, thank you";
?>
謝謝你做的一切!
似乎沒有工作... :( – tibewww
試圖剝離標籤後描繪出$消息的價值..檢查是否有仍然是一些標籤 –
我得到了它$結果= strip_tags($結果);//添加此刪除html標籤和所有 乾杯 – tibewww