jQuizzy电子邮件为空

I have the same question as: I need help sending jQuizzy results Via email it was never solved on the question, anyone have any thoughts? I tried everything on the link above.

This is my code:

$.ajax({
type: 'POST',
dataType: 'text/json',
url: config.sendResultsURL,
data: '[' + collate.join(",") + ']',
complete: function () {console.log("OH HAI");}
});

$name = $_POST['name'];
$to = "email@gmail.com";
$subject = "Quiz Score";
$header = "Content-Type: text/html
Reply-To: $to
From: $name <$email>";
$jsonStr = $_POST["ajax"];
$json = json_decode($jsonStr);

$body = "$name scored: $json";

mail($to, $subject, $body, $header);

This is the data that gets sent to the php file:

[{questionNumber:"1", UserAnswer:"1"},{questionNumber:"2", UserAnswer:"1"},{questionNumber:"3", UserAnswer:"1"},{questionNumber:"4", UserAnswer:"1"}]:

Update: followed instructions from an answer and there was a request to see my updated send.php file:

<?php
    $name = $_POST['name'];
    $to = "email@gmail.com";
    $subject = "Quiz Score";
    $header = "Content-Type: text/html
Reply-To: $to
From: $name <$email>";
    $jsonStr = $_POST["ajax"];
    $json = json_decode($jsonStr);

    $body = "$name scored: ".var_dump($json)."";

    mail($to, $subject, $body, $header);
?>

There's a few problems here.

  1. $json = $_POST["ajax"]; should be $jsonStr = $_POST["ajax"];
  2. $json is then an array - you need to access the elements of it to work out the score.
  3. The JSON is malformed - json_decode expects fields to be surrounded by speech marks (") as well as the values.

From what I can see, there's no way to pass through what the correct answers are so you'd have to know them in advance and put them in your PHP script to check against the user submitted ones, but I've never used jQuizzy, so I'm guessing!