Fammi sapereCodice PHP:function showAnswers($answers,$questions) {
for($x = 0; $x< count($answers); $x++) {
if ($x % 2 == 0) {
$output = "<div class=\"qanda clear\">\n";
} else {
$output = "<div class=\"qanda\">";
}
$output .= '<h4>Domanda' . ($x+1) . ': ' . $questions[$x] . '</h4>';
$output .= "[list=1]\n";
for ($y = 0;$y< count($answers[$x]); $y++) {
if (($answers[$x][$y] === $answers[$x][0]) && (in_array($answers[$x][$y],$_SESSION['correct']))) {
$output .= "<li class=\"correctuser\">{$answers[$x][$y]} (Corretta!)\n";
} else if ($answers[$x][$y] === $answers[$x][0]) {
$output .= "<li class=\"correct\">{$answers[$x][$y]}\n";
} else if (in_array($answers[$x][$y],$_SESSION['wrong'])) {
$output .= "<li class=\"wrong\">{$answers[$x][$y]} (Erratta!)\n";
} else {
$output .= "[*]{$answers[$x][$y]}\n";
}
}
$output .= "[/list]</div>\n";
return $output;
}
$to = "xxxx@email.com";
$subject = "Risultato quiz di $_SESSION[user]";
$message = "Nome: $_SESSION[user],
";
$message .= "Cognome: $_SESSION[codverifica]
";
$message .= "Risultati:
".showAnswers();
$headers = "From: $_SESSION[email]". "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to,$subject,$message,$headers);

Rispondi quotando