When posting HTML/PHP code, please use the board's respective bbcode tags (ex.
for PHP code) as it makes your code much easier to read and analyze. I've already added these tags to your post for you, but please keep this in mind for the future.
To answer your question, you could handle valid/invalid answers as you go:
if(empty($_POST['q1']))
echo 'Question 1 incorrect (no answer)<br>';
elseif($_POST['q1'] == 'A') {
$score++;
echo 'Question 1 correct...<br>';
} else
echo 'Question 2 incorrect (your answer: ' . $_POST['q1'] . ', correct answer: A)<br>';
// etc. for all questions
As you can see, this is a little rough in terms of scalability. You could generalize the output and loop through an array of questions/answers you specify, ex.:
$correct = array(1 => 'A', 2 => 'B', 3 => 'C');
$score = 0;
foreach($correct as $q_num => $correct_ans) {
if(empty($_POST['q'.$q_num]))
echo "Question $q_num incorrect (no answer)<br>";
elseif($_POST['q'.$q_num] == $correct_ans) {
$score++;
echo 'Question $q_num correct!<br>';
} else
echo 'Question $q_num incorrect (your answer: ' . $_POST['q'.$q_num] . ", correct answer: $correct_ans)<br>";
}
echo "Total correct: $score";