I am looking to send the results from the jQuery quiz "jQuizzy," via email.
This is the code that is sending the POST to file named send.php
if (config.sendResultsURL !== null)
{
console.log("OH HAI");
var collate =[];
for (r=0;r<userAnswers.length;r++)
{
collate.push('{questionNumber:"'+parseInt(r+1)+'", UserAnswer:"'+userAnswers[r]+'"}');
}
$.ajax({
type: 'POST',
url: "send.php",
data: '[' + collate.join(",") + ']',
complete: function () {console.log("OH HAI");}
});
}
and here is the simple PHP code to send the email.
<?php
$to = "example@example.com";
$subject = "jQuizzy!";
$jsonStr = $_POST["ajax"];
$json = json_decode($jsonStr);
$body = "$json";
mail($to, $subject, $body);
?>
EDIT: Sorry the issue is that I the results are being posted to the send.php page because the email is going through, but the email is plain/empty.
EDIT 2: I didn't even think about checking the php-error logs to which I found out my server didn't have any set up, but after setting them up it seems there are no errors on the php side of things.