I hope I am posting at the right forum.
I am a newbie to PHP. I have developed a quiz. It's working great except I am having problems with check box, multiple answers.
I have 6 questions. 5 questions are radio button, single answers. Question 6 is checkbox multiple answer. Answers for Q1-Q5 are picked up but Q6 is not. Could someone please tell me what I am doing wrong. I am sure it's a simple thing but I've been staring at it for a while now and am not getting it.
if($HTTP_POST_VARS["q1"] == "c") $correctAnswers++;
if($HTTP_POST_VARS["q2"] == "b") $correctAnswers++;
if($HTTP_POST_VARS["q3"] == "a") $correctAnswers++;
if($HTTP_POST_VARS["q4"] == "d") $correctAnswers++;
if($HTTP_POST_VARS["q5"] == "c") $correctAnswers++;
if($HTTP_POST_VARS["q6"] == "b, c") $correctAnswers++;
switch($correctAnswers)
{
case $correctAnswers < 4:
echo "Keep studying. Total marks: $correctAnswers";
break;
case $correctAnswers >= 5:
echo "Very Good! Total marks: $correctAnswers";
break;
}
I am a newbie to PHP. I have developed a quiz. It's working great except I am having problems with check box, multiple answers.
I have 6 questions. 5 questions are radio button, single answers. Question 6 is checkbox multiple answer. Answers for Q1-Q5 are picked up but Q6 is not. Could someone please tell me what I am doing wrong. I am sure it's a simple thing but I've been staring at it for a while now and am not getting it.
if($HTTP_POST_VARS["q1"] == "c") $correctAnswers++;
if($HTTP_POST_VARS["q2"] == "b") $correctAnswers++;
if($HTTP_POST_VARS["q3"] == "a") $correctAnswers++;
if($HTTP_POST_VARS["q4"] == "d") $correctAnswers++;
if($HTTP_POST_VARS["q5"] == "c") $correctAnswers++;
if($HTTP_POST_VARS["q6"] == "b, c") $correctAnswers++;
switch($correctAnswers)
{
case $correctAnswers < 4:
echo "Keep studying. Total marks: $correctAnswers";
break;
case $correctAnswers >= 5:
echo "Very Good! Total marks: $correctAnswers";
break;
}