I'm writing a small little webpage with 5 sickle cell anemia questions. I'm using the isset function to check the form elements and see if the user has selected a radio button for all 5 questions. But I cannot seem to make it work. What am I doing wrong?
<?php
if (isset($_POST['q1','q2','q3','q4','q5'])) {
echo 'Your score is <font size="24" color="red">' . $score . '</font> out of 100';
} else {
echo "Please answer all questions";
}
?>
You are not writing isset in correct way:-
if (isset($_POST["q1"],$_POST["q2"],$_POST["q3"],$_POST["q4"],$_POST["q5"])) {
echo 'Your score is <font size="24" color="red">' . $score . '</font> out of 100';
} else {
echo "Please answer all questions";
}
?>
If not understandable or you want to know exactly how's it working then read isset and array manual please.