将所选单选按钮与表格中的字段进行比较

How do I check the selected radio button value with the value stored in a database field? Code is below:

index.php:

    dfdfdffdfdfdfdf

question.php

$_POST['answer'];
$totalCorrect = 0;

if ($_POST == 'CorrectAnswer') { $totalCorrect++;}

echo "$totalCorrect questions correct";

I want to pass the answer chosen to check it with the database to see if it matches the value of CorrectAnswer and edit the score accordingly.

You missed to access the 'answer' index when accessing $_POST. Use:

if ($_POST['answer'] == 'CorrectAnswer') { $totalCorrect++;}

instead.

try something like this:

if ($_POST['answer'] == 'CorrectAnswer') { $totalCorrect++;}

N.B. you don't need the method attribute on your submit button as this is already declared in the <form> tag.