I want to know if the user clicks the submit button, it will check if the user checks all radiobuttons.
This is what I've tried so far:
$stmt = $conn->prepare( "SELECT *
FROM tblquiz ORDER BY rand()" );
$stmt->execute();
?>
<form method="post" action="checkquiz.php">
<?php
$number = 0;
for($i=0; $row = $stmt->fetch(); $i++){
$number++;
$id = $row['_id'];
$question = $row['question'];
$answers = array($row['answer1'],$row['answer2'],$row['answer3'],$row['correctanswer']);
shuffle($answers);
?>
<h4> <?php echo $number . ".) " . $question; ?></h4>
<label><input type="radio" value="<?php echo $answers[0]; ?>" name="<?php echo $question; ?>"> <?php echo $answers[0]; ?></label>
<label><input type="radio" value="<?php echo $answers[1]; ?>" name="<?php echo $question; ?>"> <?php echo $answers[1]; ?></label>
<label><input type="radio" value="<?php echo $answers[2]; ?>" name="<?php echo $question; ?>"> <?php echo $answers[2]; ?></label>
<label><input type="radio" value="<?php echo $answers[3]; ?>" name="<?php echo $question; ?>"> <?php echo $answers[3]; ?></label>
<?php
}
?>
<br />
<br />
<input type="submit" value="Submit" name="submit">
</form>
CheckQuiz.php
<?php
if( isset($_POST['submit'])) {
//echo 'You clicked submit!';
if( ){
} else {
}
} else {
echo "You didn't click submit!";
}
?>
Im a newbie so I really need your help. I want check first if all radio buttons have been checked and then check if the user's answers. Can you give me sample implementations of this? Your help will truly be appreciated Thanks.